/* 
 * converter.cxx
 *
 * Copyright 2011-2013 ESTEVE Olivier <naskel .[.at.]. gmail.com>
 *
 * This software is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this software; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 *
 * $Log: converter.cxx,v $
 *
 *
 *
 *
 *
 *
 * 
 * 
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h> // for memcpy

#include "converter.h"
#include "table.h"

static CONV cnv_fnc[FMT_LAST][FMT_LAST];
	
#define CLIP(color)					(uchar)(((color)>0xFF)?0xff:(((color)<0)?0:(color)))
#define PACK_PIXEL_RGB565(r, g, b)	( ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3) )

#define TABLE(in,out)	_##in##bit_to_##out##bit_table

#define header_fnc		( void *bsrc, void *bdst, const int width, const int height )

#define PIX_CPY(fmt)															\
	void fmt ## _to_ ## fmt header_fnc									\
		{ fast_memcpy( bdst, bsrc, width * height * sizeof( struct PIXEL_## fmt ) ); }	\

#define OP_IN( fmtIn,fmtOut, op0, op1, op2 )						\
	void fmtIn ## _to_## fmtOut header_fnc {						\
		struct PIXEL_ ## fmtIn *  src = (struct PIXEL_ ## fmtIn *)bsrc;	\
		struct PIXEL_ ## fmtOut*  dst = (struct PIXEL_ ## fmtOut*)bdst;	\
		int size = width * height;									\
		while (size--) {											\
			(*dst).r = op0; (*dst).g = op1; (*dst).b = op2;

#define PIX_OP_RGB(fmtIn,fmtOut,op0,op1,op2)	\
			OP_IN(fmtIn,fmtOut,op0,op1,op2)		\
			(void)*dst++; (void)*src++;	}}

#define PIX_OP_RGBA(fmtIn,fmtOut, op0, op1, op2, alpha )	\
			OP_IN(fmtIn,fmtOut,op0,op1,op2)					\
			(*dst).a = alpha;								\
			(void)*dst++; (void)*src++;	}}

#define SRC_R			(*src).r
#define SRC_G			(*src).g
#define SRC_B			(*src).b
#define SRC_A			(*src).a

#define TABLE_SR(a,b)	TABLE(a,b)[SRC_R]
#define TABLE_SG(a,b)	TABLE(a,b)[SRC_G]
#define TABLE_SB(a,b)	TABLE(a,b)[SRC_B]
#define TABLE_SA(a,b)	TABLE(a,b)[SRC_A]

// -- RGB444 ---------------------------------------------------------------------------------------------
PIX_CPY				( RGB444 );
PIX_OP_RGBA			( RGB444,	RGBA4441,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGBA			( RGB444,	RGBA4444,	SRC_R, SRC_G, SRC_B, 0x0F );
PIX_OP_RGB			( RGB444,	RGB555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( RGB444,	RGBA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), 1 );
PIX_OP_RGB			( RGB444,	RGB565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( RGB444,	RGB888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( RGB444,	RGBA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), 255 );
PIX_OP_RGB			( RGB444,	BGR444,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( RGB444,	ABGR1444,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGBA			( RGB444,	ABGR4444,	SRC_R, SRC_G, SRC_B, 0x0F );
PIX_OP_RGB			( RGB444,	BGR555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( RGB444,	ABGR1555,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), 1 );
PIX_OP_RGB			( RGB444,	BGR565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( RGB444,	BGR888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( RGB444,	ABGR8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), 255 );
PIX_OP_RGBA			( RGB444,	BGRA4441,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGBA			( RGB444,	BGRA4444,	SRC_R, SRC_G, SRC_B, 0x0F );
PIX_OP_RGBA			( RGB444,	BGRA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), 1 );
PIX_OP_RGBA			( RGB444,	BGRA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), 255 );
PIX_OP_RGB			( RGB444,	RGB332,		TABLE_SR(4,3), TABLE_SG(4,3), TABLE_SB(4,2) );
PIX_OP_RGB			( RGB444,	BGR332,		TABLE_SR(4,2), TABLE_SG(4,3), TABLE_SB(4,3) );
PIX_OP_RGBA			( RGB444,	RGBA5542,	TABLE_SR(4,5), TABLE_SG(4,5), SRC_B, 1 );
PIX_OP_RGBA			( RGB444,	ABGR2554,	SRC_R, TABLE_SG(4,5), TABLE_SB(4,5), 1 );
PIX_OP_RGBA			( RGB444,	RGBA6661,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), 1 );
PIX_OP_RGBA			( RGB444,	ABGR1666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), 1 );
PIX_OP_RGBA			( RGB444,	RGBA6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), 0x0F );
PIX_OP_RGBA			( RGB444,	ABGR6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), 0x0F );
PIX_OP_RGB			( RGB444,	RGB666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGB			( RGB444,	BGR666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGBA			( RGB444,	RGBA5658,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), 255 );
PIX_OP_RGBA			( RGB444,	ABGR8565,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), 255 );
// -- RGBA4441 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( RGBA4441,	RGB444,		SRC_R, SRC_G, SRC_B );
PIX_CPY				( RGBA4441 );
PIX_OP_RGBA			( RGBA4441,	RGBA4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( RGBA4441,	RGB555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( RGBA4441,	RGBA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGB			( RGBA4441,	RGB565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( RGBA4441,	RGB888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( RGBA4441,	RGBA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGB			( RGBA4441,	BGR444,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( RGBA4441,	ABGR1444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA4441,	ABGR4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( RGBA4441,	BGR555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( RGBA4441,	ABGR1555,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGB			( RGBA4441,	BGR565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( RGBA4441,	BGR888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( RGBA4441,	ABGR8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGBA			( RGBA4441,	BGRA4441,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA4441,	BGRA4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA4441,	BGRA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( RGBA4441,	BGRA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGB			( RGBA4441,	RGB332,		TABLE_SR(4,3), TABLE_SG(4,3), TABLE_SB(4,2) );
PIX_OP_RGB			( RGBA4441,	BGR332,		TABLE_SR(4,2), TABLE_SG(4,3), TABLE_SB(4,3) );
PIX_OP_RGBA			( RGBA4441,	RGBA5542,	TABLE_SR(4,5), TABLE_SG(4,5), SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA4441,	ABGR2554,	SRC_R, TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( RGBA4441,	RGBA6661,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( RGBA4441,	ABGR1666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( RGBA4441,	RGBA6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( RGBA4441,	ABGR6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGB			( RGBA4441,	RGB666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGB			( RGBA4441,	BGR666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGBA			( RGBA4441,	RGBA5658,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( RGBA4441,	ABGR8565,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), SRC_A );
// -- RGBA4444 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( RGBA4444,	RGB444,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( RGBA4444,	RGBA4441,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_CPY				( RGBA4444 );
PIX_OP_RGB			( RGBA4444,	RGB555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( RGBA4444,	RGBA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGB			( RGBA4444,	RGB565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( RGBA4444,	RGB888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( RGBA4444,	RGBA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGB			( RGBA4444,	BGR444,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( RGBA4444,	ABGR1444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA4444,	ABGR4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( RGBA4444,	BGR555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( RGBA4444,	ABGR1555,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGB			( RGBA4444,	BGR565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( RGBA4444,	BGR888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( RGBA4444,	ABGR8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGBA			( RGBA4444,	BGRA4441,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA4444,	BGRA4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA4444,	BGRA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( RGBA4444,	BGRA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGB			( RGBA4444,	RGB332,		TABLE_SR(4,3), TABLE_SG(4,3), TABLE_SB(4,2) );
PIX_OP_RGB			( RGBA4444,	BGR332,		TABLE_SR(4,2), TABLE_SG(4,3), TABLE_SB(4,3) );
PIX_OP_RGBA			( RGBA4444,	RGBA5542,	TABLE_SR(4,5), TABLE_SG(4,5), SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA4444,	ABGR2554,	SRC_R, TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( RGBA4444,	RGBA6661,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( RGBA4444,	ABGR1666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( RGBA4444,	RGBA6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( RGBA4444,	ABGR6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGB			( RGBA4444,	RGB666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGB			( RGBA4444,	BGR666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGBA			( RGBA4444,	RGBA5658,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( RGBA4444,	ABGR8565,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), SRC_A );
// -- RGB555 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( RGB555,	RGB444,		TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( RGB555,	RGBA4441,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( RGB555,	RGBA4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), 0x0F );
PIX_CPY				( RGB555 );
PIX_OP_RGBA			( RGB555,	RGBA5551,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGB			( RGB555,	RGB565,		SRC_R, TABLE_SG(5,6), SRC_B );
PIX_OP_RGB			( RGB555,	RGB888,		TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( RGB555,	RGBA8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), 255 );
PIX_OP_RGB			( RGB555,	BGR444,		TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( RGB555,	ABGR1444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( RGB555,	ABGR4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), 0x0F );
PIX_OP_RGB			( RGB555,	BGR555,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( RGB555,	ABGR1555,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGB			( RGB555,	BGR565,		SRC_R, TABLE_SG(5,6), SRC_B );
PIX_OP_RGB			( RGB555,	BGR888,		TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( RGB555,	ABGR8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), 255 );
PIX_OP_RGBA			( RGB555,	BGRA4441,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( RGB555,	BGRA4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), 0x0F );
PIX_OP_RGBA			( RGB555,	BGRA5551,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGBA			( RGB555,	BGRA8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), 255 );
PIX_OP_RGB			( RGB555,	RGB332,		TABLE_SR(5,3), TABLE_SG(5,3), TABLE_SB(5,2) );
PIX_OP_RGB			( RGB555,	BGR332,		TABLE_SR(5,2), TABLE_SG(5,3), TABLE_SB(5,3) );
PIX_OP_RGBA			( RGB555,	RGBA5542,	SRC_R, SRC_G, TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( RGB555,	ABGR2554,	TABLE_SR(5,4), SRC_G, SRC_B, 1 );
PIX_OP_RGBA			( RGB555,	RGBA6661,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), 1 );
PIX_OP_RGBA			( RGB555,	ABGR1666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), 1 );
PIX_OP_RGBA			( RGB555,	RGBA6666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), 0x0F );
PIX_OP_RGBA			( RGB555,	ABGR6666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), 0x0F );
PIX_OP_RGB			( RGB555,	RGB666,		TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6) );
PIX_OP_RGB			( RGB555,	BGR666,		TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6) );
PIX_OP_RGBA			( RGB555,	RGBA5658,	SRC_R, TABLE_SG(5,6), SRC_B, 255 );
PIX_OP_RGBA			( RGB555,	ABGR8565,	SRC_R, TABLE_SG(5,6), SRC_B, 255 );
// -- RGBA5551 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( RGBA5551,	RGB444,		TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( RGBA5551,	RGBA4441,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( RGBA5551,	RGBA4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGB			( RGBA5551,	RGB555,		SRC_R, SRC_G, SRC_B );
PIX_CPY				( RGBA5551 );
PIX_OP_RGB			( RGBA5551,	RGB565,		SRC_R, TABLE_SG(5,6), SRC_B );
PIX_OP_RGB			( RGBA5551,	RGB888,		TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( RGBA5551,	RGBA8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGB			( RGBA5551,	BGR444,		TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( RGBA5551,	ABGR1444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( RGBA5551,	ABGR4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGB			( RGBA5551,	BGR555,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( RGBA5551,	ABGR1555,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( RGBA5551,	BGR565,		SRC_R, TABLE_SG(5,6), SRC_B );
PIX_OP_RGB			( RGBA5551,	BGR888,		TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( RGBA5551,	ABGR8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGBA			( RGBA5551,	BGRA4441,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( RGBA5551,	BGRA4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( RGBA5551,	BGRA5551,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA5551,	BGRA8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGB			( RGBA5551,	RGB332,		TABLE_SR(5,3), TABLE_SG(5,3), TABLE_SB(5,2) );
PIX_OP_RGB			( RGBA5551,	BGR332,		TABLE_SR(5,2), TABLE_SG(5,3), TABLE_SB(5,3) );
PIX_OP_RGBA			( RGBA5551,	RGBA5542,	SRC_R, SRC_G, TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( RGBA5551,	ABGR2554,	TABLE_SR(5,4), SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA5551,	RGBA6661,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( RGBA5551,	ABGR1666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( RGBA5551,	RGBA6666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( RGBA5551,	ABGR6666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGB			( RGBA5551,	RGB666,		TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6) );
PIX_OP_RGB			( RGBA5551,	BGR666,		TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6) );
PIX_OP_RGBA			( RGBA5551,	RGBA5658,	SRC_R, TABLE_SG(5,6), SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA5551,	ABGR8565,	SRC_R, TABLE_SG(5,6), SRC_B, SRC_A );
// -- RGB565 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( RGB565,	RGB444,		TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( RGB565,	RGBA4441,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( RGB565,	RGBA4444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), 0x0F );
PIX_OP_RGB			( RGB565,	RGB555,		SRC_R, TABLE_SG(6,5), SRC_B );
PIX_OP_RGBA			( RGB565,	RGBA5551,	SRC_R, TABLE_SG(6,5), SRC_B, 1 );
PIX_CPY				( RGB565 );
PIX_OP_RGB			( RGB565,	RGB888,		TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( RGB565,	RGBA8888,	TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8), 255 );
PIX_OP_RGB			( RGB565,	BGR444,		TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( RGB565,	ABGR1444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( RGB565,	ABGR4444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), 0x0F );
PIX_OP_RGB			( RGB565,	BGR555,		SRC_R, TABLE_SG(6,5), SRC_B );
PIX_OP_RGBA			( RGB565,	ABGR1555,	SRC_R, TABLE_SG(6,5), SRC_B, 1 );
PIX_OP_RGB			( RGB565,	BGR565,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGB			( RGB565,	BGR888,		TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( RGB565,	ABGR8888,	TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8), 255 );
PIX_OP_RGBA			( RGB565,	BGRA4441,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( RGB565,	BGRA4444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), 0x0F );
PIX_OP_RGBA			( RGB565,	BGRA5551,	SRC_R, TABLE_SG(6,5), SRC_B, 1 );
PIX_OP_RGBA			( RGB565,	BGRA8888,	TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8), 255 );
PIX_OP_RGB			( RGB565,	RGB332,		TABLE_SR(5,3), TABLE_SG(6,3), TABLE_SB(5,2) );
PIX_OP_RGB			( RGB565,	BGR332,		TABLE_SR(5,2), TABLE_SG(6,3), TABLE_SB(5,3) );
PIX_OP_RGBA			( RGB565,	RGBA5542,	SRC_R, TABLE_SG(6,5), TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( RGB565,	ABGR2554,	TABLE_SR(5,4), TABLE_SG(6,5), SRC_B, 1 );
PIX_OP_RGBA			( RGB565,	RGBA6661,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), 1 );
PIX_OP_RGBA			( RGB565,	ABGR1666,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), 1 );
PIX_OP_RGBA			( RGB565,	RGBA6666,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), 0x0F );
PIX_OP_RGBA			( RGB565,	ABGR6666,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), 0x0F );
PIX_OP_RGB			( RGB565,	RGB666,		TABLE_SR(5,6), SRC_G, TABLE_SB(5,6) );
PIX_OP_RGB			( RGB565,	BGR666,		TABLE_SR(5,6), SRC_G, TABLE_SB(5,6) );
PIX_OP_RGBA			( RGB565,	RGBA5658,	SRC_R, SRC_G, SRC_B, 255 );
PIX_OP_RGBA			( RGB565,	ABGR8565,	SRC_R, SRC_G, SRC_B, 255 );
// -- RGB888 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( RGB888,	RGB444,		TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4) );
PIX_OP_RGBA			( RGB888,	RGBA4441,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), 1 );
PIX_OP_RGBA			( RGB888,	RGBA4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), 0x0F );
PIX_OP_RGB			( RGB888,	RGB555,		TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5) );
PIX_OP_RGBA			( RGB888,	RGBA5551,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), 1 );
PIX_OP_RGB			( RGB888,	RGB565,		TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5) );
PIX_CPY				( RGB888 );
PIX_OP_RGBA			( RGB888,	RGBA8888,	SRC_R, SRC_G, SRC_B, 255 );
PIX_OP_RGB			( RGB888,	BGR444,		TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4) );
PIX_OP_RGBA			( RGB888,	ABGR1444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), 1 );
PIX_OP_RGBA			( RGB888,	ABGR4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), 0x0F );
PIX_OP_RGB			( RGB888,	BGR555,		TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5) );
PIX_OP_RGBA			( RGB888,	ABGR1555,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), 1 );
PIX_OP_RGB			( RGB888,	BGR565,		TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5) );
PIX_OP_RGB			( RGB888,	BGR888,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( RGB888,	ABGR8888,	SRC_R, SRC_G, SRC_B, 255 );
PIX_OP_RGBA			( RGB888,	BGRA4441,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), 1 );
PIX_OP_RGBA			( RGB888,	BGRA4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), 0x0F );
PIX_OP_RGBA			( RGB888,	BGRA5551,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), 1 );
PIX_OP_RGBA			( RGB888,	BGRA8888,	SRC_R, SRC_G, SRC_B, 255 );
PIX_OP_RGB			( RGB888,	RGB332,		TABLE_SR(8,3), TABLE_SG(8,3), TABLE_SB(8,2) );
PIX_OP_RGB			( RGB888,	BGR332,		TABLE_SR(8,2), TABLE_SG(8,3), TABLE_SB(8,3) );
PIX_OP_RGBA			( RGB888,	RGBA5542,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,4), 1 );
PIX_OP_RGBA			( RGB888,	ABGR2554,	TABLE_SR(8,4), TABLE_SG(8,5), TABLE_SB(8,5), 1 );
PIX_OP_RGBA			( RGB888,	RGBA6661,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), 1 );
PIX_OP_RGBA			( RGB888,	ABGR1666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), 1 );
PIX_OP_RGBA			( RGB888,	RGBA6666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), 0x0F );
PIX_OP_RGBA			( RGB888,	ABGR6666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), 0x0F );
PIX_OP_RGB			( RGB888,	RGB666,		TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6) );
PIX_OP_RGB			( RGB888,	BGR666,		TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6) );
PIX_OP_RGBA			( RGB888,	RGBA5658,	TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5), 255 );
PIX_OP_RGBA			( RGB888,	ABGR8565,	TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5), 255 );
// -- RGBA8888 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( RGBA8888,	RGB444,		TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4) );
PIX_OP_RGBA			( RGBA8888,	RGBA4441,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( RGBA8888,	RGBA4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGB			( RGBA8888,	RGB555,		TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5) );
PIX_OP_RGBA			( RGBA8888,	RGBA5551,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), SRC_A );
PIX_OP_RGB			( RGBA8888,	RGB565,		TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5) );
PIX_OP_RGB			( RGBA8888,	RGB888,		SRC_R, SRC_G, SRC_B );
PIX_CPY				( RGBA8888 );
PIX_OP_RGB			( RGBA8888,	BGR444,		TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4) );
PIX_OP_RGBA			( RGBA8888,	ABGR1444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( RGBA8888,	ABGR4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGB			( RGBA8888,	BGR555,		TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5) );
PIX_OP_RGBA			( RGBA8888,	ABGR1555,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), SRC_A );
PIX_OP_RGB			( RGBA8888,	BGR565,		TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5) );
PIX_OP_RGB			( RGBA8888,	BGR888,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( RGBA8888,	ABGR8888,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA8888,	BGRA4441,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( RGBA8888,	BGRA4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( RGBA8888,	BGRA5551,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), SRC_A );
PIX_OP_RGBA			( RGBA8888,	BGRA8888,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( RGBA8888,	RGB332,		TABLE_SR(8,3), TABLE_SG(8,3), TABLE_SB(8,2) );
PIX_OP_RGB			( RGBA8888,	BGR332,		TABLE_SR(8,2), TABLE_SG(8,3), TABLE_SB(8,3) );
PIX_OP_RGBA			( RGBA8888,	RGBA5542,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( RGBA8888,	ABGR2554,	TABLE_SR(8,4), TABLE_SG(8,5), TABLE_SB(8,5), SRC_A );
PIX_OP_RGBA			( RGBA8888,	RGBA6661,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), SRC_A );
PIX_OP_RGBA			( RGBA8888,	ABGR1666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), SRC_A );
PIX_OP_RGBA			( RGBA8888,	RGBA6666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), TABLE_SA(8,6) );
PIX_OP_RGBA			( RGBA8888,	ABGR6666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), TABLE_SA(8,6) );
PIX_OP_RGB			( RGBA8888,	RGB666,		TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6) );
PIX_OP_RGB			( RGBA8888,	BGR666,		TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6) );
PIX_OP_RGBA			( RGBA8888,	RGBA5658,	TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5), SRC_A );
PIX_OP_RGBA			( RGBA8888,	ABGR8565,	TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5), SRC_A );
// -- BGR444 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( BGR444,	RGB444,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( BGR444,	RGBA4441,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGBA			( BGR444,	RGBA4444,	SRC_R, SRC_G, SRC_B, 0x0F );
PIX_OP_RGB			( BGR444,	RGB555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( BGR444,	RGBA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), 1 );
PIX_OP_RGB			( BGR444,	RGB565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( BGR444,	RGB888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( BGR444,	RGBA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), 255 );
PIX_CPY				( BGR444 );
PIX_OP_RGBA			( BGR444,	ABGR1444,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGBA			( BGR444,	ABGR4444,	SRC_R, SRC_G, SRC_B, 0x0F );
PIX_OP_RGB			( BGR444,	BGR555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( BGR444,	ABGR1555,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), 1 );
PIX_OP_RGB			( BGR444,	BGR565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( BGR444,	BGR888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( BGR444,	ABGR8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), 255 );
PIX_OP_RGBA			( BGR444,	BGRA4441,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGBA			( BGR444,	BGRA4444,	SRC_R, SRC_G, SRC_B, 0x0F );
PIX_OP_RGBA			( BGR444,	BGRA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), 1 );
PIX_OP_RGBA			( BGR444,	BGRA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), 255 );
PIX_OP_RGB			( BGR444,	RGB332,		TABLE_SR(4,3), TABLE_SG(4,3), TABLE_SB(4,2) );
PIX_OP_RGB			( BGR444,	BGR332,		TABLE_SR(4,2), TABLE_SG(4,3), TABLE_SB(4,3) );
PIX_OP_RGBA			( BGR444,	RGBA5542,	TABLE_SR(4,5), TABLE_SG(4,5), SRC_B, 1 );
PIX_OP_RGBA			( BGR444,	ABGR2554,	SRC_R, TABLE_SG(4,5), TABLE_SB(4,5), 1 );
PIX_OP_RGBA			( BGR444,	RGBA6661,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), 1 );
PIX_OP_RGBA			( BGR444,	ABGR1666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), 1 );
PIX_OP_RGBA			( BGR444,	RGBA6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), 0x0F );
PIX_OP_RGBA			( BGR444,	ABGR6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), 0x0F );
PIX_OP_RGB			( BGR444,	RGB666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGB			( BGR444,	BGR666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGBA			( BGR444,	RGBA5658,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), 255 );
PIX_OP_RGBA			( BGR444,	ABGR8565,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), 255 );
// -- ABGR1444 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( ABGR1444,	RGB444,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( ABGR1444,	RGBA4441,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR1444,	RGBA4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( ABGR1444,	RGB555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( ABGR1444,	RGBA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGB			( ABGR1444,	RGB565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( ABGR1444,	RGB888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( ABGR1444,	RGBA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGB			( ABGR1444,	BGR444,		SRC_R, SRC_G, SRC_B );
PIX_CPY				( ABGR1444 );
PIX_OP_RGBA			( ABGR1444,	ABGR4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( ABGR1444,	BGR555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( ABGR1444,	ABGR1555,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGB			( ABGR1444,	BGR565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( ABGR1444,	BGR888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( ABGR1444,	ABGR8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGBA			( ABGR1444,	BGRA4441,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR1444,	BGRA4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR1444,	BGRA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( ABGR1444,	BGRA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGB			( ABGR1444,	RGB332,		TABLE_SR(4,3), TABLE_SG(4,3), TABLE_SB(4,2) );
PIX_OP_RGB			( ABGR1444,	BGR332,		TABLE_SR(4,2), TABLE_SG(4,3), TABLE_SB(4,3) );
PIX_OP_RGBA			( ABGR1444,	RGBA5542,	TABLE_SR(4,5), TABLE_SG(4,5), SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR1444,	ABGR2554,	SRC_R, TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( ABGR1444,	RGBA6661,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( ABGR1444,	ABGR1666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( ABGR1444,	RGBA6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( ABGR1444,	ABGR6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGB			( ABGR1444,	RGB666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGB			( ABGR1444,	BGR666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGBA			( ABGR1444,	RGBA5658,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( ABGR1444,	ABGR8565,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), SRC_A );
// -- ABGR4444 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( ABGR4444,	RGB444,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( ABGR4444,	RGBA4441,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR4444,	RGBA4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( ABGR4444,	RGB555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( ABGR4444,	RGBA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGB			( ABGR4444,	RGB565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( ABGR4444,	RGB888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( ABGR4444,	RGBA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGB			( ABGR4444,	BGR444,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( ABGR4444,	ABGR1444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_CPY				( ABGR4444 );
PIX_OP_RGB			( ABGR4444,	BGR555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( ABGR4444,	ABGR1555,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGB			( ABGR4444,	BGR565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( ABGR4444,	BGR888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( ABGR4444,	ABGR8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGBA			( ABGR4444,	BGRA4441,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR4444,	BGRA4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR4444,	BGRA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( ABGR4444,	BGRA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGB			( ABGR4444,	RGB332,		TABLE_SR(4,3), TABLE_SG(4,3), TABLE_SB(4,2) );
PIX_OP_RGB			( ABGR4444,	BGR332,		TABLE_SR(4,2), TABLE_SG(4,3), TABLE_SB(4,3) );
PIX_OP_RGBA			( ABGR4444,	RGBA5542,	TABLE_SR(4,5), TABLE_SG(4,5), SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR4444,	ABGR2554,	SRC_R, TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( ABGR4444,	RGBA6661,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( ABGR4444,	ABGR1666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( ABGR4444,	RGBA6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( ABGR4444,	ABGR6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGB			( ABGR4444,	RGB666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGB			( ABGR4444,	BGR666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGBA			( ABGR4444,	RGBA5658,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( ABGR4444,	ABGR8565,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), SRC_A );
// -- BGR555 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( BGR555,	RGB444,		TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( BGR555,	RGBA4441,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( BGR555,	RGBA4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), 0x0F );
PIX_OP_RGB			( BGR555,	RGB555,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( BGR555,	RGBA5551,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGB			( BGR555,	RGB565,		SRC_R, TABLE_SG(5,6), SRC_B );
PIX_OP_RGB			( BGR555,	RGB888,		TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( BGR555,	RGBA8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), 255 );
PIX_OP_RGB			( BGR555,	BGR444,		TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( BGR555,	ABGR1444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( BGR555,	ABGR4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), 0x0F );
PIX_CPY				( BGR555 );
PIX_OP_RGBA			( BGR555,	ABGR1555,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGB			( BGR555,	BGR565,		SRC_R, TABLE_SG(5,6), SRC_B );
PIX_OP_RGB			( BGR555,	BGR888,		TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( BGR555,	ABGR8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), 255 );
PIX_OP_RGBA			( BGR555,	BGRA4441,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( BGR555,	BGRA4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), 0x0F );
PIX_OP_RGBA			( BGR555,	BGRA5551,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGBA			( BGR555,	BGRA8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), 255 );
PIX_OP_RGB			( BGR555,	RGB332,		TABLE_SR(5,3), TABLE_SG(5,3), TABLE_SB(5,2) );
PIX_OP_RGB			( BGR555,	BGR332,		TABLE_SR(5,2), TABLE_SG(5,3), TABLE_SB(5,3) );
PIX_OP_RGBA			( BGR555,	RGBA5542,	SRC_R, SRC_G, TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( BGR555,	ABGR2554,	TABLE_SR(5,4), SRC_G, SRC_B, 1 );
PIX_OP_RGBA			( BGR555,	RGBA6661,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), 1 );
PIX_OP_RGBA			( BGR555,	ABGR1666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), 1 );
PIX_OP_RGBA			( BGR555,	RGBA6666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), 0x0F );
PIX_OP_RGBA			( BGR555,	ABGR6666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), 0x0F );
PIX_OP_RGB			( BGR555,	RGB666,		TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6) );
PIX_OP_RGB			( BGR555,	BGR666,		TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6) );
PIX_OP_RGBA			( BGR555,	RGBA5658,	SRC_R, TABLE_SG(5,6), SRC_B, 255 );
PIX_OP_RGBA			( BGR555,	ABGR8565,	SRC_R, TABLE_SG(5,6), SRC_B, 255 );
// -- ABGR1555 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( ABGR1555,	RGB444,		TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( ABGR1555,	RGBA4441,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( ABGR1555,	RGBA4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGB			( ABGR1555,	RGB555,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( ABGR1555,	RGBA5551,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( ABGR1555,	RGB565,		SRC_R, TABLE_SG(5,6), SRC_B );
PIX_OP_RGB			( ABGR1555,	RGB888,		TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( ABGR1555,	RGBA8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGB			( ABGR1555,	BGR444,		TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( ABGR1555,	ABGR1444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( ABGR1555,	ABGR4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGB			( ABGR1555,	BGR555,		SRC_R, SRC_G, SRC_B );
PIX_CPY				( ABGR1555 );
PIX_OP_RGB			( ABGR1555,	BGR565,		SRC_R, TABLE_SG(5,6), SRC_B );
PIX_OP_RGB			( ABGR1555,	BGR888,		TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( ABGR1555,	ABGR8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGBA			( ABGR1555,	BGRA4441,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( ABGR1555,	BGRA4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( ABGR1555,	BGRA5551,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR1555,	BGRA8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGB			( ABGR1555,	RGB332,		TABLE_SR(5,3), TABLE_SG(5,3), TABLE_SB(5,2) );
PIX_OP_RGB			( ABGR1555,	BGR332,		TABLE_SR(5,2), TABLE_SG(5,3), TABLE_SB(5,3) );
PIX_OP_RGBA			( ABGR1555,	RGBA5542,	SRC_R, SRC_G, TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( ABGR1555,	ABGR2554,	TABLE_SR(5,4), SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR1555,	RGBA6661,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( ABGR1555,	ABGR1666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( ABGR1555,	RGBA6666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( ABGR1555,	ABGR6666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGB			( ABGR1555,	RGB666,		TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6) );
PIX_OP_RGB			( ABGR1555,	BGR666,		TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6) );
PIX_OP_RGBA			( ABGR1555,	RGBA5658,	SRC_R, TABLE_SG(5,6), SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR1555,	ABGR8565,	SRC_R, TABLE_SG(5,6), SRC_B, SRC_A );
// -- BGR565 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( BGR565,	RGB444,		TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( BGR565,	RGBA4441,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( BGR565,	RGBA4444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), 0x0F );
PIX_OP_RGB			( BGR565,	RGB555,		SRC_R, TABLE_SG(6,5), SRC_B );
PIX_OP_RGBA			( BGR565,	RGBA5551,	SRC_R, TABLE_SG(6,5), SRC_B, 1 );
PIX_OP_RGB			( BGR565,	RGB565,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGB			( BGR565,	RGB888,		TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( BGR565,	RGBA8888,	TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8), 255 );
PIX_OP_RGB			( BGR565,	BGR444,		TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( BGR565,	ABGR1444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( BGR565,	ABGR4444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), 0x0F );
PIX_OP_RGB			( BGR565,	BGR555,		SRC_R, TABLE_SG(6,5), SRC_B );
PIX_OP_RGBA			( BGR565,	ABGR1555,	SRC_R, TABLE_SG(6,5), SRC_B, 1 );
PIX_CPY				( BGR565 );
PIX_OP_RGB			( BGR565,	BGR888,		TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( BGR565,	ABGR8888,	TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8), 255 );
PIX_OP_RGBA			( BGR565,	BGRA4441,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( BGR565,	BGRA4444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), 0x0F );
PIX_OP_RGBA			( BGR565,	BGRA5551,	SRC_R, TABLE_SG(6,5), SRC_B, 1 );
PIX_OP_RGBA			( BGR565,	BGRA8888,	TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8), 255 );
PIX_OP_RGB			( BGR565,	RGB332,		TABLE_SR(5,3), TABLE_SG(6,3), TABLE_SB(5,2) );
PIX_OP_RGB			( BGR565,	BGR332,		TABLE_SR(5,2), TABLE_SG(6,3), TABLE_SB(5,3) );
PIX_OP_RGBA			( BGR565,	RGBA5542,	SRC_R, TABLE_SG(6,5), TABLE_SB(5,4), 1 );
PIX_OP_RGBA			( BGR565,	ABGR2554,	TABLE_SR(5,4), TABLE_SG(6,5), SRC_B, 1 );
PIX_OP_RGBA			( BGR565,	RGBA6661,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), 1 );
PIX_OP_RGBA			( BGR565,	ABGR1666,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), 1 );
PIX_OP_RGBA			( BGR565,	RGBA6666,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), 0x0F );
PIX_OP_RGBA			( BGR565,	ABGR6666,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), 0x0F );
PIX_OP_RGB			( BGR565,	RGB666,		TABLE_SR(5,6), SRC_G, TABLE_SB(5,6) );
PIX_OP_RGB			( BGR565,	BGR666,		TABLE_SR(5,6), SRC_G, TABLE_SB(5,6) );
PIX_OP_RGBA			( BGR565,	RGBA5658,	SRC_R, SRC_G, SRC_B, 255 );
PIX_OP_RGBA			( BGR565,	ABGR8565,	SRC_R, SRC_G, SRC_B, 255 );
// -- BGR888 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( BGR888,	RGB444,		TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4) );
PIX_OP_RGBA			( BGR888,	RGBA4441,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), 1 );
PIX_OP_RGBA			( BGR888,	RGBA4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), 0x0F );
PIX_OP_RGB			( BGR888,	RGB555,		TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5) );
PIX_OP_RGBA			( BGR888,	RGBA5551,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), 1 );
PIX_OP_RGB			( BGR888,	RGB565,		TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5) );
PIX_OP_RGB			( BGR888,	RGB888,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( BGR888,	RGBA8888,	SRC_R, SRC_G, SRC_B, 255 );
PIX_OP_RGB			( BGR888,	BGR444,		TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4) );
PIX_OP_RGBA			( BGR888,	ABGR1444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), 1 );
PIX_OP_RGBA			( BGR888,	ABGR4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), 0x0F );
PIX_OP_RGB			( BGR888,	BGR555,		TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5) );
PIX_OP_RGBA			( BGR888,	ABGR1555,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), 1 );
PIX_OP_RGB			( BGR888,	BGR565,		TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5) );
PIX_CPY				( BGR888 );
PIX_OP_RGBA			( BGR888,	ABGR8888,	SRC_R, SRC_G, SRC_B, 255 );
PIX_OP_RGBA			( BGR888,	BGRA4441,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), 1 );
PIX_OP_RGBA			( BGR888,	BGRA4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), 0x0F );
PIX_OP_RGBA			( BGR888,	BGRA5551,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), 1 );
PIX_OP_RGBA			( BGR888,	BGRA8888,	SRC_R, SRC_G, SRC_B, 255 );
PIX_OP_RGB			( BGR888,	RGB332,		TABLE_SR(8,3), TABLE_SG(8,3), TABLE_SB(8,2) );
PIX_OP_RGB			( BGR888,	BGR332,		TABLE_SR(8,2), TABLE_SG(8,3), TABLE_SB(8,3) );
PIX_OP_RGBA			( BGR888,	RGBA5542,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,4), 1 );
PIX_OP_RGBA			( BGR888,	ABGR2554,	TABLE_SR(8,4), TABLE_SG(8,5), TABLE_SB(8,5), 1 );
PIX_OP_RGBA			( BGR888,	RGBA6661,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), 1 );
PIX_OP_RGBA			( BGR888,	ABGR1666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), 1 );
PIX_OP_RGBA			( BGR888,	RGBA6666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), 0x0F );
PIX_OP_RGBA			( BGR888,	ABGR6666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), 0x0F );
PIX_OP_RGB			( BGR888,	RGB666,		TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6) );
PIX_OP_RGB			( BGR888,	BGR666,		TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6) );
PIX_OP_RGBA			( BGR888,	RGBA5658,	TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5), 255 );
PIX_OP_RGBA			( BGR888,	ABGR8565,	TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5), 255 );
// -- ABGR8888 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( ABGR8888,	RGB444,		TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4) );
PIX_OP_RGBA			( ABGR8888,	RGBA4441,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( ABGR8888,	RGBA4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGB			( ABGR8888,	RGB555,		TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5) );
PIX_OP_RGBA			( ABGR8888,	RGBA5551,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), SRC_A );
PIX_OP_RGB			( ABGR8888,	RGB565,		TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5) );
PIX_OP_RGB			( ABGR8888,	RGB888,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( ABGR8888,	RGBA8888,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( ABGR8888,	BGR444,		TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4) );
PIX_OP_RGBA			( ABGR8888,	ABGR1444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( ABGR8888,	ABGR4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGB			( ABGR8888,	BGR555,		TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5) );
PIX_OP_RGBA			( ABGR8888,	ABGR1555,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), SRC_A );
PIX_OP_RGB			( ABGR8888,	BGR565,		TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5) );
PIX_OP_RGB			( ABGR8888,	BGR888,		SRC_R, SRC_G, SRC_B );
PIX_CPY				( ABGR8888 );
PIX_OP_RGBA			( ABGR8888,	BGRA4441,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( ABGR8888,	BGRA4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( ABGR8888,	BGRA5551,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), SRC_A );
PIX_OP_RGBA			( ABGR8888,	BGRA8888,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( ABGR8888,	RGB332,		TABLE_SR(8,3), TABLE_SG(8,3), TABLE_SB(8,2) );
PIX_OP_RGB			( ABGR8888,	BGR332,		TABLE_SR(8,2), TABLE_SG(8,3), TABLE_SB(8,3) );
PIX_OP_RGBA			( ABGR8888,	RGBA5542,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( ABGR8888,	ABGR2554,	TABLE_SR(8,4), TABLE_SG(8,5), TABLE_SB(8,5), SRC_A );
PIX_OP_RGBA			( ABGR8888,	RGBA6661,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), SRC_A );
PIX_OP_RGBA			( ABGR8888,	ABGR1666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), SRC_A );
PIX_OP_RGBA			( ABGR8888,	RGBA6666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), TABLE_SA(8,6) );
PIX_OP_RGBA			( ABGR8888,	ABGR6666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), TABLE_SA(8,6) );
PIX_OP_RGB			( ABGR8888,	RGB666,		TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6) );
PIX_OP_RGB			( ABGR8888,	BGR666,		TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6) );
PIX_OP_RGBA			( ABGR8888,	RGBA5658,	TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5), SRC_A );
PIX_OP_RGBA			( ABGR8888,	ABGR8565,	TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5), SRC_A );
// -- BGRA4441 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( BGRA4441,	RGB444,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( BGRA4441,	RGBA4441,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( BGRA4441,	RGBA4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( BGRA4441,	RGB555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( BGRA4441,	RGBA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGB			( BGRA4441,	RGB565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( BGRA4441,	RGB888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( BGRA4441,	RGBA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGB			( BGRA4441,	BGR444,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( BGRA4441,	ABGR1444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( BGRA4441,	ABGR4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( BGRA4441,	BGR555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( BGRA4441,	ABGR1555,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGB			( BGRA4441,	BGR565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( BGRA4441,	BGR888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( BGRA4441,	ABGR8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_CPY				( BGRA4441 );
PIX_OP_RGBA			( BGRA4441,	BGRA4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( BGRA4441,	BGRA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( BGRA4441,	BGRA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGB			( BGRA4441,	RGB332,		TABLE_SR(4,3), TABLE_SG(4,3), TABLE_SB(4,2) );
PIX_OP_RGB			( BGRA4441,	BGR332,		TABLE_SR(4,2), TABLE_SG(4,3), TABLE_SB(4,3) );
PIX_OP_RGBA			( BGRA4441,	RGBA5542,	TABLE_SR(4,5), TABLE_SG(4,5), SRC_B, SRC_A );
PIX_OP_RGBA			( BGRA4441,	ABGR2554,	SRC_R, TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( BGRA4441,	RGBA6661,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( BGRA4441,	ABGR1666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( BGRA4441,	RGBA6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( BGRA4441,	ABGR6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGB			( BGRA4441,	RGB666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGB			( BGRA4441,	BGR666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGBA			( BGRA4441,	RGBA5658,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( BGRA4441,	ABGR8565,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), SRC_A );
// -- BGRA4444 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( BGRA4444,	RGB444,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( BGRA4444,	RGBA4441,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( BGRA4444,	RGBA4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( BGRA4444,	RGB555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( BGRA4444,	RGBA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGB			( BGRA4444,	RGB565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( BGRA4444,	RGB888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( BGRA4444,	RGBA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGB			( BGRA4444,	BGR444,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( BGRA4444,	ABGR1444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( BGRA4444,	ABGR4444,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( BGRA4444,	BGR555,		TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5) );
PIX_OP_RGBA			( BGRA4444,	ABGR1555,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGB			( BGRA4444,	BGR565,		TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5) );
PIX_OP_RGB			( BGRA4444,	BGR888,		TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( BGRA4444,	ABGR8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGBA			( BGRA4444,	BGRA4441,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_CPY				( BGRA4444 );
PIX_OP_RGBA			( BGRA4444,	BGRA5551,	TABLE_SR(4,5), TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( BGRA4444,	BGRA8888,	TABLE_SR(4,8), TABLE_SG(4,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGB			( BGRA4444,	RGB332,		TABLE_SR(4,3), TABLE_SG(4,3), TABLE_SB(4,2) );
PIX_OP_RGB			( BGRA4444,	BGR332,		TABLE_SR(4,2), TABLE_SG(4,3), TABLE_SB(4,3) );
PIX_OP_RGBA			( BGRA4444,	RGBA5542,	TABLE_SR(4,5), TABLE_SG(4,5), SRC_B, SRC_A );
PIX_OP_RGBA			( BGRA4444,	ABGR2554,	SRC_R, TABLE_SG(4,5), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( BGRA4444,	RGBA6661,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( BGRA4444,	ABGR1666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( BGRA4444,	RGBA6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( BGRA4444,	ABGR6666,	TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGB			( BGRA4444,	RGB666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGB			( BGRA4444,	BGR666,		TABLE_SR(4,6), TABLE_SG(4,6), TABLE_SB(4,6) );
PIX_OP_RGBA			( BGRA4444,	RGBA5658,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( BGRA4444,	ABGR8565,	TABLE_SR(4,5), TABLE_SG(4,6), TABLE_SB(4,5), SRC_A );
// -- BGRA5551 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( BGRA5551,	RGB444,		TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( BGRA5551,	RGBA4441,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( BGRA5551,	RGBA4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGB			( BGRA5551,	RGB555,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( BGRA5551,	RGBA5551,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( BGRA5551,	RGB565,		SRC_R, TABLE_SG(5,6), SRC_B );
PIX_OP_RGB			( BGRA5551,	RGB888,		TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( BGRA5551,	RGBA8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGB			( BGRA5551,	BGR444,		TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( BGRA5551,	ABGR1444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( BGRA5551,	ABGR4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGB			( BGRA5551,	BGR555,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( BGRA5551,	ABGR1555,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( BGRA5551,	BGR565,		SRC_R, TABLE_SG(5,6), SRC_B );
PIX_OP_RGB			( BGRA5551,	BGR888,		TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( BGRA5551,	ABGR8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGBA			( BGRA5551,	BGRA4441,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( BGRA5551,	BGRA4444,	TABLE_SR(5,4), TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_CPY				( BGRA5551 );
PIX_OP_RGBA			( BGRA5551,	BGRA8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGB			( BGRA5551,	RGB332,		TABLE_SR(5,3), TABLE_SG(5,3), TABLE_SB(5,2) );
PIX_OP_RGB			( BGRA5551,	BGR332,		TABLE_SR(5,2), TABLE_SG(5,3), TABLE_SB(5,3) );
PIX_OP_RGBA			( BGRA5551,	RGBA5542,	SRC_R, SRC_G, TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( BGRA5551,	ABGR2554,	TABLE_SR(5,4), SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( BGRA5551,	RGBA6661,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( BGRA5551,	ABGR1666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( BGRA5551,	RGBA6666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( BGRA5551,	ABGR6666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGB			( BGRA5551,	RGB666,		TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6) );
PIX_OP_RGB			( BGRA5551,	BGR666,		TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(5,6) );
PIX_OP_RGBA			( BGRA5551,	RGBA5658,	SRC_R, TABLE_SG(5,6), SRC_B, SRC_A );
PIX_OP_RGBA			( BGRA5551,	ABGR8565,	SRC_R, TABLE_SG(5,6), SRC_B, SRC_A );
// -- BGRA8888 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( BGRA8888,	RGB444,		TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4) );
PIX_OP_RGBA			( BGRA8888,	RGBA4441,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( BGRA8888,	RGBA4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGB			( BGRA8888,	RGB555,		TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5) );
PIX_OP_RGBA			( BGRA8888,	RGBA5551,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), SRC_A );
PIX_OP_RGB			( BGRA8888,	RGB565,		TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5) );
PIX_OP_RGB			( BGRA8888,	RGB888,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( BGRA8888,	RGBA8888,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( BGRA8888,	BGR444,		TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4) );
PIX_OP_RGBA			( BGRA8888,	ABGR1444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( BGRA8888,	ABGR4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGB			( BGRA8888,	BGR555,		TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5) );
PIX_OP_RGBA			( BGRA8888,	ABGR1555,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), SRC_A );
PIX_OP_RGB			( BGRA8888,	BGR565,		TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5) );
PIX_OP_RGB			( BGRA8888,	BGR888,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( BGRA8888,	ABGR8888,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( BGRA8888,	BGRA4441,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( BGRA8888,	BGRA4444,	TABLE_SR(8,4), TABLE_SG(8,4), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( BGRA8888,	BGRA5551,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,5), SRC_A );
PIX_CPY				( BGRA8888 );
PIX_OP_RGB			( BGRA8888,	RGB332,		TABLE_SR(8,3), TABLE_SG(8,3), TABLE_SB(8,2) );
PIX_OP_RGB			( BGRA8888,	BGR332,		TABLE_SR(8,2), TABLE_SG(8,3), TABLE_SB(8,3) );
PIX_OP_RGBA			( BGRA8888,	RGBA5542,	TABLE_SR(8,5), TABLE_SG(8,5), TABLE_SB(8,4), SRC_A );
PIX_OP_RGBA			( BGRA8888,	ABGR2554,	TABLE_SR(8,4), TABLE_SG(8,5), TABLE_SB(8,5), SRC_A );
PIX_OP_RGBA			( BGRA8888,	RGBA6661,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), SRC_A );
PIX_OP_RGBA			( BGRA8888,	ABGR1666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), SRC_A );
PIX_OP_RGBA			( BGRA8888,	RGBA6666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), TABLE_SA(8,6) );
PIX_OP_RGBA			( BGRA8888,	ABGR6666,	TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6), TABLE_SA(8,6) );
PIX_OP_RGB			( BGRA8888,	RGB666,		TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6) );
PIX_OP_RGB			( BGRA8888,	BGR666,		TABLE_SR(8,6), TABLE_SG(8,6), TABLE_SB(8,6) );
PIX_OP_RGBA			( BGRA8888,	RGBA5658,	TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5), SRC_A );
PIX_OP_RGBA			( BGRA8888,	ABGR8565,	TABLE_SR(8,5), TABLE_SG(8,6), TABLE_SB(8,5), SRC_A );
// -- RGB332 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( RGB332,	RGB444,		TABLE_SR(3,4), TABLE_SG(3,4), TABLE_SB(2,4) );
PIX_OP_RGBA			( RGB332,	RGBA4441,	TABLE_SR(3,4), TABLE_SG(3,4), TABLE_SB(2,4), 1 );
PIX_OP_RGBA			( RGB332,	RGBA4444,	TABLE_SR(3,4), TABLE_SG(3,4), TABLE_SB(2,4), 0x0F );
PIX_OP_RGB			( RGB332,	RGB555,		TABLE_SR(3,5), TABLE_SG(3,5), TABLE_SB(2,5) );
PIX_OP_RGBA			( RGB332,	RGBA5551,	TABLE_SR(3,5), TABLE_SG(3,5), TABLE_SB(2,5), 1 );
PIX_OP_RGB			( RGB332,	RGB565,		TABLE_SR(3,5), TABLE_SG(3,6), TABLE_SB(2,5) );
PIX_OP_RGB			( RGB332,	RGB888,		TABLE_SR(3,8), TABLE_SG(3,8), TABLE_SB(2,8) );
PIX_OP_RGBA			( RGB332,	RGBA8888,	TABLE_SR(3,8), TABLE_SG(3,8), TABLE_SB(2,8), 255 );
PIX_OP_RGB			( RGB332,	BGR444,		TABLE_SR(3,4), TABLE_SG(3,4), TABLE_SB(2,4) );
PIX_OP_RGBA			( RGB332,	ABGR1444,	TABLE_SR(3,4), TABLE_SG(3,4), TABLE_SB(2,4), 1 );
PIX_OP_RGBA			( RGB332,	ABGR4444,	TABLE_SR(3,4), TABLE_SG(3,4), TABLE_SB(2,4), 0x0F );
PIX_OP_RGB			( RGB332,	BGR555,		TABLE_SR(3,5), TABLE_SG(3,5), TABLE_SB(2,5) );
PIX_OP_RGBA			( RGB332,	ABGR1555,	TABLE_SR(3,5), TABLE_SG(3,5), TABLE_SB(2,5), 1 );
PIX_OP_RGB			( RGB332,	BGR565,		TABLE_SR(3,5), TABLE_SG(3,6), TABLE_SB(2,5) );
PIX_OP_RGB			( RGB332,	BGR888,		TABLE_SR(3,8), TABLE_SG(3,8), TABLE_SB(2,8) );
PIX_OP_RGBA			( RGB332,	ABGR8888,	TABLE_SR(3,8), TABLE_SG(3,8), TABLE_SB(2,8), 255 );
PIX_OP_RGBA			( RGB332,	BGRA4441,	TABLE_SR(3,4), TABLE_SG(3,4), TABLE_SB(2,4), 1 );
PIX_OP_RGBA			( RGB332,	BGRA4444,	TABLE_SR(3,4), TABLE_SG(3,4), TABLE_SB(2,4), 0x0F );
PIX_OP_RGBA			( RGB332,	BGRA5551,	TABLE_SR(3,5), TABLE_SG(3,5), TABLE_SB(2,5), 1 );
PIX_OP_RGBA			( RGB332,	BGRA8888,	TABLE_SR(3,8), TABLE_SG(3,8), TABLE_SB(2,8), 255 );
PIX_CPY				( RGB332 );
PIX_OP_RGB			( RGB332,	BGR332,		TABLE_SR(3,2), SRC_G, TABLE_SB(2,3) );
PIX_OP_RGBA			( RGB332,	RGBA5542,	TABLE_SR(3,5), TABLE_SG(3,5), TABLE_SB(2,4), 1 );
PIX_OP_RGBA			( RGB332,	ABGR2554,	TABLE_SR(3,4), TABLE_SG(3,5), TABLE_SB(2,5), 1 );
PIX_OP_RGBA			( RGB332,	RGBA6661,	TABLE_SR(3,6), TABLE_SG(3,6), TABLE_SB(2,6), 1 );
PIX_OP_RGBA			( RGB332,	ABGR1666,	TABLE_SR(3,6), TABLE_SG(3,6), TABLE_SB(2,6), 1 );
PIX_OP_RGBA			( RGB332,	RGBA6666,	TABLE_SR(3,6), TABLE_SG(3,6), TABLE_SB(2,6), 0x0F );
PIX_OP_RGBA			( RGB332,	ABGR6666,	TABLE_SR(3,6), TABLE_SG(3,6), TABLE_SB(2,6), 0x0F );
PIX_OP_RGB			( RGB332,	RGB666,		TABLE_SR(3,6), TABLE_SG(3,6), TABLE_SB(2,6) );
PIX_OP_RGB			( RGB332,	BGR666,		TABLE_SR(3,6), TABLE_SG(3,6), TABLE_SB(2,6) );
PIX_OP_RGBA			( RGB332,	RGBA5658,	TABLE_SR(3,5), TABLE_SG(3,6), TABLE_SB(2,5), 255 );
PIX_OP_RGBA			( RGB332,	ABGR8565,	TABLE_SR(3,5), TABLE_SG(3,6), TABLE_SB(2,5), 255 );
// -- BGR332 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( BGR332,	RGB444,		TABLE_SR(2,4), TABLE_SG(3,4), TABLE_SB(3,4) );
PIX_OP_RGBA			( BGR332,	RGBA4441,	TABLE_SR(2,4), TABLE_SG(3,4), TABLE_SB(3,4), 1 );
PIX_OP_RGBA			( BGR332,	RGBA4444,	TABLE_SR(2,4), TABLE_SG(3,4), TABLE_SB(3,4), 0x0F );
PIX_OP_RGB			( BGR332,	RGB555,		TABLE_SR(2,5), TABLE_SG(3,5), TABLE_SB(3,5) );
PIX_OP_RGBA			( BGR332,	RGBA5551,	TABLE_SR(2,5), TABLE_SG(3,5), TABLE_SB(3,5), 1 );
PIX_OP_RGB			( BGR332,	RGB565,		TABLE_SR(2,5), TABLE_SG(3,6), TABLE_SB(3,5) );
PIX_OP_RGB			( BGR332,	RGB888,		TABLE_SR(2,8), TABLE_SG(3,8), TABLE_SB(3,8) );
PIX_OP_RGBA			( BGR332,	RGBA8888,	TABLE_SR(2,8), TABLE_SG(3,8), TABLE_SB(3,8), 255 );
PIX_OP_RGB			( BGR332,	BGR444,		TABLE_SR(2,4), TABLE_SG(3,4), TABLE_SB(3,4) );
PIX_OP_RGBA			( BGR332,	ABGR1444,	TABLE_SR(2,4), TABLE_SG(3,4), TABLE_SB(3,4), 1 );
PIX_OP_RGBA			( BGR332,	ABGR4444,	TABLE_SR(2,4), TABLE_SG(3,4), TABLE_SB(3,4), 0x0F );
PIX_OP_RGB			( BGR332,	BGR555,		TABLE_SR(2,5), TABLE_SG(3,5), TABLE_SB(3,5) );
PIX_OP_RGBA			( BGR332,	ABGR1555,	TABLE_SR(2,5), TABLE_SG(3,5), TABLE_SB(3,5), 1 );
PIX_OP_RGB			( BGR332,	BGR565,		TABLE_SR(2,5), TABLE_SG(3,6), TABLE_SB(3,5) );
PIX_OP_RGB			( BGR332,	BGR888,		TABLE_SR(2,8), TABLE_SG(3,8), TABLE_SB(3,8) );
PIX_OP_RGBA			( BGR332,	ABGR8888,	TABLE_SR(2,8), TABLE_SG(3,8), TABLE_SB(3,8), 255 );
PIX_OP_RGBA			( BGR332,	BGRA4441,	TABLE_SR(2,4), TABLE_SG(3,4), TABLE_SB(3,4), 1 );
PIX_OP_RGBA			( BGR332,	BGRA4444,	TABLE_SR(2,4), TABLE_SG(3,4), TABLE_SB(3,4), 0x0F );
PIX_OP_RGBA			( BGR332,	BGRA5551,	TABLE_SR(2,5), TABLE_SG(3,5), TABLE_SB(3,5), 1 );
PIX_OP_RGBA			( BGR332,	BGRA8888,	TABLE_SR(2,8), TABLE_SG(3,8), TABLE_SB(3,8), 255 );
PIX_OP_RGB			( BGR332,	RGB332,		TABLE_SR(2,3), SRC_G, TABLE_SB(3,2) );
PIX_CPY				( BGR332 );
PIX_OP_RGBA			( BGR332,	RGBA5542,	TABLE_SR(2,5), TABLE_SG(3,5), TABLE_SB(3,4), 1 );
PIX_OP_RGBA			( BGR332,	ABGR2554,	TABLE_SR(2,4), TABLE_SG(3,5), TABLE_SB(3,5), 1 );
PIX_OP_RGBA			( BGR332,	RGBA6661,	TABLE_SR(2,6), TABLE_SG(3,6), TABLE_SB(3,6), 1 );
PIX_OP_RGBA			( BGR332,	ABGR1666,	TABLE_SR(2,6), TABLE_SG(3,6), TABLE_SB(3,6), 1 );
PIX_OP_RGBA			( BGR332,	RGBA6666,	TABLE_SR(2,6), TABLE_SG(3,6), TABLE_SB(3,6), 0x0F );
PIX_OP_RGBA			( BGR332,	ABGR6666,	TABLE_SR(2,6), TABLE_SG(3,6), TABLE_SB(3,6), 0x0F );
PIX_OP_RGB			( BGR332,	RGB666,		TABLE_SR(2,6), TABLE_SG(3,6), TABLE_SB(3,6) );
PIX_OP_RGB			( BGR332,	BGR666,		TABLE_SR(2,6), TABLE_SG(3,6), TABLE_SB(3,6) );
PIX_OP_RGBA			( BGR332,	RGBA5658,	TABLE_SR(2,5), TABLE_SG(3,6), TABLE_SB(3,5), 255 );
PIX_OP_RGBA			( BGR332,	ABGR8565,	TABLE_SR(2,5), TABLE_SG(3,6), TABLE_SB(3,5), 255 );
// -- RGBA5542 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( RGBA5542,	RGB444,		TABLE_SR(5,4), TABLE_SG(5,4), SRC_B );
PIX_OP_RGBA			( RGBA5542,	RGBA4441,	TABLE_SR(5,4), TABLE_SG(5,4), SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA5542,	RGBA4444,	TABLE_SR(5,4), TABLE_SG(5,4), SRC_B, SRC_A );
PIX_OP_RGB			( RGBA5542,	RGB555,		SRC_R, SRC_G, TABLE_SB(4,5) );
PIX_OP_RGBA			( RGBA5542,	RGBA5551,	SRC_R, SRC_G, TABLE_SB(4,5), SRC_A );
PIX_OP_RGB			( RGBA5542,	RGB565,		SRC_R, TABLE_SG(5,6), TABLE_SB(4,5) );
PIX_OP_RGB			( RGBA5542,	RGB888,		TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( RGBA5542,	RGBA8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGB			( RGBA5542,	BGR444,		TABLE_SR(5,4), TABLE_SG(5,4), SRC_B );
PIX_OP_RGBA			( RGBA5542,	ABGR1444,	TABLE_SR(5,4), TABLE_SG(5,4), SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA5542,	ABGR4444,	TABLE_SR(5,4), TABLE_SG(5,4), SRC_B, SRC_A );
PIX_OP_RGB			( RGBA5542,	BGR555,		SRC_R, SRC_G, TABLE_SB(4,5) );
PIX_OP_RGBA			( RGBA5542,	ABGR1555,	SRC_R, SRC_G, TABLE_SB(4,5), SRC_A );
PIX_OP_RGB			( RGBA5542,	BGR565,		SRC_R, TABLE_SG(5,6), TABLE_SB(4,5) );
PIX_OP_RGB			( RGBA5542,	BGR888,		TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(4,8) );
PIX_OP_RGBA			( RGBA5542,	ABGR8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGBA			( RGBA5542,	BGRA4441,	TABLE_SR(5,4), TABLE_SG(5,4), SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA5542,	BGRA4444,	TABLE_SR(5,4), TABLE_SG(5,4), SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA5542,	BGRA5551,	SRC_R, SRC_G, TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( RGBA5542,	BGRA8888,	TABLE_SR(5,8), TABLE_SG(5,8), TABLE_SB(4,8), SRC_A );
PIX_OP_RGB			( RGBA5542,	RGB332,		TABLE_SR(5,3), TABLE_SG(5,3), TABLE_SB(4,2) );
PIX_OP_RGB			( RGBA5542,	BGR332,		TABLE_SR(5,2), TABLE_SG(5,3), TABLE_SB(4,3) );
PIX_CPY				( RGBA5542 );
PIX_OP_RGBA			( RGBA5542,	ABGR2554,	TABLE_SR(5,4), SRC_G, TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( RGBA5542,	RGBA6661,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( RGBA5542,	ABGR1666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( RGBA5542,	RGBA6666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGBA			( RGBA5542,	ABGR6666,	TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(4,6), SRC_A );
PIX_OP_RGB			( RGBA5542,	RGB666,		TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(4,6) );
PIX_OP_RGB			( RGBA5542,	BGR666,		TABLE_SR(5,6), TABLE_SG(5,6), TABLE_SB(4,6) );
PIX_OP_RGBA			( RGBA5542,	RGBA5658,	SRC_R, TABLE_SG(5,6), TABLE_SB(4,5), SRC_A );
PIX_OP_RGBA			( RGBA5542,	ABGR8565,	SRC_R, TABLE_SG(5,6), TABLE_SB(4,5), SRC_A );
// -- ABGR2554 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( ABGR2554,	RGB444,		SRC_R, TABLE_SG(5,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( ABGR2554,	RGBA4441,	SRC_R, TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( ABGR2554,	RGBA4444,	SRC_R, TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGB			( ABGR2554,	RGB555,		TABLE_SR(4,5), SRC_G, SRC_B );
PIX_OP_RGBA			( ABGR2554,	RGBA5551,	TABLE_SR(4,5), SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( ABGR2554,	RGB565,		TABLE_SR(4,5), TABLE_SG(5,6), SRC_B );
PIX_OP_RGB			( ABGR2554,	RGB888,		TABLE_SR(4,8), TABLE_SG(5,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( ABGR2554,	RGBA8888,	TABLE_SR(4,8), TABLE_SG(5,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGB			( ABGR2554,	BGR444,		SRC_R, TABLE_SG(5,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( ABGR2554,	ABGR1444,	SRC_R, TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( ABGR2554,	ABGR4444,	SRC_R, TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGB			( ABGR2554,	BGR555,		TABLE_SR(4,5), SRC_G, SRC_B );
PIX_OP_RGBA			( ABGR2554,	ABGR1555,	TABLE_SR(4,5), SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( ABGR2554,	BGR565,		TABLE_SR(4,5), TABLE_SG(5,6), SRC_B );
PIX_OP_RGB			( ABGR2554,	BGR888,		TABLE_SR(4,8), TABLE_SG(5,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( ABGR2554,	ABGR8888,	TABLE_SR(4,8), TABLE_SG(5,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGBA			( ABGR2554,	BGRA4441,	SRC_R, TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( ABGR2554,	BGRA4444,	SRC_R, TABLE_SG(5,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( ABGR2554,	BGRA5551,	TABLE_SR(4,5), SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR2554,	BGRA8888,	TABLE_SR(4,8), TABLE_SG(5,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGB			( ABGR2554,	RGB332,		TABLE_SR(4,3), TABLE_SG(5,3), TABLE_SB(5,2) );
PIX_OP_RGB			( ABGR2554,	BGR332,		TABLE_SR(4,2), TABLE_SG(5,3), TABLE_SB(5,3) );
PIX_OP_RGBA			( ABGR2554,	RGBA5542,	TABLE_SR(4,5), SRC_G, TABLE_SB(5,4), SRC_A );
PIX_CPY				( ABGR2554 );
PIX_OP_RGBA			( ABGR2554,	RGBA6661,	TABLE_SR(4,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( ABGR2554,	ABGR1666,	TABLE_SR(4,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( ABGR2554,	RGBA6666,	TABLE_SR(4,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( ABGR2554,	ABGR6666,	TABLE_SR(4,6), TABLE_SG(5,6), TABLE_SB(5,6), SRC_A );
PIX_OP_RGB			( ABGR2554,	RGB666,		TABLE_SR(4,6), TABLE_SG(5,6), TABLE_SB(5,6) );
PIX_OP_RGB			( ABGR2554,	BGR666,		TABLE_SR(4,6), TABLE_SG(5,6), TABLE_SB(5,6) );
PIX_OP_RGBA			( ABGR2554,	RGBA5658,	TABLE_SR(4,5), TABLE_SG(5,6), SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR2554,	ABGR8565,	TABLE_SR(4,5), TABLE_SG(5,6), SRC_B, SRC_A );
// -- RGBA6661 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( RGBA6661,	RGB444,		TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4) );
PIX_OP_RGBA			( RGBA6661,	RGBA4441,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( RGBA6661,	RGBA4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGB			( RGBA6661,	RGB555,		TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5) );
PIX_OP_RGBA			( RGBA6661,	RGBA5551,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGB			( RGBA6661,	RGB565,		TABLE_SR(6,5), SRC_G, TABLE_SB(6,5) );
PIX_OP_RGB			( RGBA6661,	RGB888,		TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8) );
PIX_OP_RGBA			( RGBA6661,	RGBA8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), SRC_A );
PIX_OP_RGB			( RGBA6661,	BGR444,		TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4) );
PIX_OP_RGBA			( RGBA6661,	ABGR1444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( RGBA6661,	ABGR4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGB			( RGBA6661,	BGR555,		TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5) );
PIX_OP_RGBA			( RGBA6661,	ABGR1555,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGB			( RGBA6661,	BGR565,		TABLE_SR(6,5), SRC_G, TABLE_SB(6,5) );
PIX_OP_RGB			( RGBA6661,	BGR888,		TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8) );
PIX_OP_RGBA			( RGBA6661,	ABGR8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), SRC_A );
PIX_OP_RGBA			( RGBA6661,	BGRA4441,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( RGBA6661,	BGRA4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( RGBA6661,	BGRA5551,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGBA			( RGBA6661,	BGRA8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), SRC_A );
PIX_OP_RGB			( RGBA6661,	RGB332,		TABLE_SR(6,3), TABLE_SG(6,3), TABLE_SB(6,2) );
PIX_OP_RGB			( RGBA6661,	BGR332,		TABLE_SR(6,2), TABLE_SG(6,3), TABLE_SB(6,3) );
PIX_OP_RGBA			( RGBA6661,	RGBA5542,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( RGBA6661,	ABGR2554,	TABLE_SR(6,4), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_CPY				( RGBA6661 );
PIX_OP_RGBA			( RGBA6661,	ABGR1666,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA6661,	RGBA6666,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA6661,	ABGR6666,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( RGBA6661,	RGB666,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGB			( RGBA6661,	BGR666,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( RGBA6661,	RGBA5658,	TABLE_SR(6,5), SRC_G, TABLE_SB(6,5), SRC_A );
PIX_OP_RGBA			( RGBA6661,	ABGR8565,	TABLE_SR(6,5), SRC_G, TABLE_SB(6,5), SRC_A );
// -- ABGR1666 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( ABGR1666,	RGB444,		TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4) );
PIX_OP_RGBA			( ABGR1666,	RGBA4441,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( ABGR1666,	RGBA4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGB			( ABGR1666,	RGB555,		TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5) );
PIX_OP_RGBA			( ABGR1666,	RGBA5551,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGB			( ABGR1666,	RGB565,		TABLE_SR(6,5), SRC_G, TABLE_SB(6,5) );
PIX_OP_RGB			( ABGR1666,	RGB888,		TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8) );
PIX_OP_RGBA			( ABGR1666,	RGBA8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), SRC_A );
PIX_OP_RGB			( ABGR1666,	BGR444,		TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4) );
PIX_OP_RGBA			( ABGR1666,	ABGR1444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( ABGR1666,	ABGR4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGB			( ABGR1666,	BGR555,		TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5) );
PIX_OP_RGBA			( ABGR1666,	ABGR1555,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGB			( ABGR1666,	BGR565,		TABLE_SR(6,5), SRC_G, TABLE_SB(6,5) );
PIX_OP_RGB			( ABGR1666,	BGR888,		TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8) );
PIX_OP_RGBA			( ABGR1666,	ABGR8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), SRC_A );
PIX_OP_RGBA			( ABGR1666,	BGRA4441,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( ABGR1666,	BGRA4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( ABGR1666,	BGRA5551,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGBA			( ABGR1666,	BGRA8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), SRC_A );
PIX_OP_RGB			( ABGR1666,	RGB332,		TABLE_SR(6,3), TABLE_SG(6,3), TABLE_SB(6,2) );
PIX_OP_RGB			( ABGR1666,	BGR332,		TABLE_SR(6,2), TABLE_SG(6,3), TABLE_SB(6,3) );
PIX_OP_RGBA			( ABGR1666,	RGBA5542,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( ABGR1666,	ABGR2554,	TABLE_SR(6,4), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGBA			( ABGR1666,	RGBA6661,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_CPY				( ABGR1666 );
PIX_OP_RGBA			( ABGR1666,	RGBA6666,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR1666,	ABGR6666,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( ABGR1666,	RGB666,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGB			( ABGR1666,	BGR666,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( ABGR1666,	RGBA5658,	TABLE_SR(6,5), SRC_G, TABLE_SB(6,5), SRC_A );
PIX_OP_RGBA			( ABGR1666,	ABGR8565,	TABLE_SR(6,5), SRC_G, TABLE_SB(6,5), SRC_A );
// -- RGBA6666 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( RGBA6666,	RGB444,		TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4) );
PIX_OP_RGBA			( RGBA6666,	RGBA4441,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( RGBA6666,	RGBA4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGB			( RGBA6666,	RGB555,		TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5) );
PIX_OP_RGBA			( RGBA6666,	RGBA5551,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGB			( RGBA6666,	RGB565,		TABLE_SR(6,5), SRC_G, TABLE_SB(6,5) );
PIX_OP_RGB			( RGBA6666,	RGB888,		TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8) );
PIX_OP_RGBA			( RGBA6666,	RGBA8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), TABLE_SA(6,8) );
PIX_OP_RGB			( RGBA6666,	BGR444,		TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4) );
PIX_OP_RGBA			( RGBA6666,	ABGR1444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( RGBA6666,	ABGR4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGB			( RGBA6666,	BGR555,		TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5) );
PIX_OP_RGBA			( RGBA6666,	ABGR1555,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGB			( RGBA6666,	BGR565,		TABLE_SR(6,5), SRC_G, TABLE_SB(6,5) );
PIX_OP_RGB			( RGBA6666,	BGR888,		TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8) );
PIX_OP_RGBA			( RGBA6666,	ABGR8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), TABLE_SA(6,8) );
PIX_OP_RGBA			( RGBA6666,	BGRA4441,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( RGBA6666,	BGRA4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( RGBA6666,	BGRA5551,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGBA			( RGBA6666,	BGRA8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), TABLE_SA(6,8) );
PIX_OP_RGB			( RGBA6666,	RGB332,		TABLE_SR(6,3), TABLE_SG(6,3), TABLE_SB(6,2) );
PIX_OP_RGB			( RGBA6666,	BGR332,		TABLE_SR(6,2), TABLE_SG(6,3), TABLE_SB(6,3) );
PIX_OP_RGBA			( RGBA6666,	RGBA5542,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( RGBA6666,	ABGR2554,	TABLE_SR(6,4), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGBA			( RGBA6666,	RGBA6661,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA6666,	ABGR1666,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_CPY				( RGBA6666 );
PIX_OP_RGBA			( RGBA6666,	ABGR6666,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGB			( RGBA6666,	RGB666,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGB			( RGBA6666,	BGR666,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( RGBA6666,	RGBA5658,	TABLE_SR(6,5), SRC_G, TABLE_SB(6,5), TABLE_SA(6,8) );
PIX_OP_RGBA			( RGBA6666,	ABGR8565,	TABLE_SR(6,5), SRC_G, TABLE_SB(6,5), TABLE_SA(6,8) );
// -- ABGR6666 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( ABGR6666,	RGB444,		TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4) );
PIX_OP_RGBA			( ABGR6666,	RGBA4441,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( ABGR6666,	RGBA4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGB			( ABGR6666,	RGB555,		TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5) );
PIX_OP_RGBA			( ABGR6666,	RGBA5551,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGB			( ABGR6666,	RGB565,		TABLE_SR(6,5), SRC_G, TABLE_SB(6,5) );
PIX_OP_RGB			( ABGR6666,	RGB888,		TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8) );
PIX_OP_RGBA			( ABGR6666,	RGBA8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), TABLE_SA(6,8) );
PIX_OP_RGB			( ABGR6666,	BGR444,		TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4) );
PIX_OP_RGBA			( ABGR6666,	ABGR1444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( ABGR6666,	ABGR4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGB			( ABGR6666,	BGR555,		TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5) );
PIX_OP_RGBA			( ABGR6666,	ABGR1555,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGB			( ABGR6666,	BGR565,		TABLE_SR(6,5), SRC_G, TABLE_SB(6,5) );
PIX_OP_RGB			( ABGR6666,	BGR888,		TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8) );
PIX_OP_RGBA			( ABGR6666,	ABGR8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), TABLE_SA(6,8) );
PIX_OP_RGBA			( ABGR6666,	BGRA4441,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( ABGR6666,	BGRA4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( ABGR6666,	BGRA5551,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGBA			( ABGR6666,	BGRA8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), TABLE_SA(6,8) );
PIX_OP_RGB			( ABGR6666,	RGB332,		TABLE_SR(6,3), TABLE_SG(6,3), TABLE_SB(6,2) );
PIX_OP_RGB			( ABGR6666,	BGR332,		TABLE_SR(6,2), TABLE_SG(6,3), TABLE_SB(6,3) );
PIX_OP_RGBA			( ABGR6666,	RGBA5542,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,4), SRC_A );
PIX_OP_RGBA			( ABGR6666,	ABGR2554,	TABLE_SR(6,4), TABLE_SG(6,5), TABLE_SB(6,5), SRC_A );
PIX_OP_RGBA			( ABGR6666,	RGBA6661,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR6666,	ABGR1666,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR6666,	RGBA6666,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_CPY				( ABGR6666 );
PIX_OP_RGB			( ABGR6666,	RGB666,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGB			( ABGR6666,	BGR666,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( ABGR6666,	RGBA5658,	TABLE_SR(6,5), SRC_G, TABLE_SB(6,5), TABLE_SA(6,8) );
PIX_OP_RGBA			( ABGR6666,	ABGR8565,	TABLE_SR(6,5), SRC_G, TABLE_SB(6,5), TABLE_SA(6,8) );
// -- RGB666 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( RGB666,	RGB444,		TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4) );
PIX_OP_RGBA			( RGB666,	RGBA4441,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), 1 );
PIX_OP_RGBA			( RGB666,	RGBA4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), 0x0F );
PIX_OP_RGB			( RGB666,	RGB555,		TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5) );
PIX_OP_RGBA			( RGB666,	RGBA5551,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), 1 );
PIX_OP_RGB			( RGB666,	RGB565,		TABLE_SR(6,5), SRC_G, TABLE_SB(6,5) );
PIX_OP_RGB			( RGB666,	RGB888,		TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8) );
PIX_OP_RGBA			( RGB666,	RGBA8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), 255 );
PIX_OP_RGB			( RGB666,	BGR444,		TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4) );
PIX_OP_RGBA			( RGB666,	ABGR1444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), 1 );
PIX_OP_RGBA			( RGB666,	ABGR4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), 0x0F );
PIX_OP_RGB			( RGB666,	BGR555,		TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5) );
PIX_OP_RGBA			( RGB666,	ABGR1555,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), 1 );
PIX_OP_RGB			( RGB666,	BGR565,		TABLE_SR(6,5), SRC_G, TABLE_SB(6,5) );
PIX_OP_RGB			( RGB666,	BGR888,		TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8) );
PIX_OP_RGBA			( RGB666,	ABGR8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), 255 );
PIX_OP_RGBA			( RGB666,	BGRA4441,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), 1 );
PIX_OP_RGBA			( RGB666,	BGRA4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), 0x0F );
PIX_OP_RGBA			( RGB666,	BGRA5551,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), 1 );
PIX_OP_RGBA			( RGB666,	BGRA8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), 255 );
PIX_OP_RGB			( RGB666,	RGB332,		TABLE_SR(6,3), TABLE_SG(6,3), TABLE_SB(6,2) );
PIX_OP_RGB			( RGB666,	BGR332,		TABLE_SR(6,2), TABLE_SG(6,3), TABLE_SB(6,3) );
PIX_OP_RGBA			( RGB666,	RGBA5542,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,4), 1 );
PIX_OP_RGBA			( RGB666,	ABGR2554,	TABLE_SR(6,4), TABLE_SG(6,5), TABLE_SB(6,5), 1 );
PIX_OP_RGBA			( RGB666,	RGBA6661,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGBA			( RGB666,	ABGR1666,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGBA			( RGB666,	RGBA6666,	SRC_R, SRC_G, SRC_B, 0x0F );
PIX_OP_RGBA			( RGB666,	ABGR6666,	SRC_R, SRC_G, SRC_B, 0x0F );
PIX_CPY				( RGB666 );
PIX_OP_RGB			( RGB666,	BGR666,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGBA			( RGB666,	RGBA5658,	TABLE_SR(6,5), SRC_G, TABLE_SB(6,5), 255 );
PIX_OP_RGBA			( RGB666,	ABGR8565,	TABLE_SR(6,5), SRC_G, TABLE_SB(6,5), 255 );
// -- BGR666 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( BGR666,	RGB444,		TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4) );
PIX_OP_RGBA			( BGR666,	RGBA4441,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), 1 );
PIX_OP_RGBA			( BGR666,	RGBA4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), 0x0F );
PIX_OP_RGB			( BGR666,	RGB555,		TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5) );
PIX_OP_RGBA			( BGR666,	RGBA5551,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), 1 );
PIX_OP_RGB			( BGR666,	RGB565,		TABLE_SR(6,5), SRC_G, TABLE_SB(6,5) );
PIX_OP_RGB			( BGR666,	RGB888,		TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8) );
PIX_OP_RGBA			( BGR666,	RGBA8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), 255 );
PIX_OP_RGB			( BGR666,	BGR444,		TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4) );
PIX_OP_RGBA			( BGR666,	ABGR1444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), 1 );
PIX_OP_RGBA			( BGR666,	ABGR4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), 0x0F );
PIX_OP_RGB			( BGR666,	BGR555,		TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5) );
PIX_OP_RGBA			( BGR666,	ABGR1555,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), 1 );
PIX_OP_RGB			( BGR666,	BGR565,		TABLE_SR(6,5), SRC_G, TABLE_SB(6,5) );
PIX_OP_RGB			( BGR666,	BGR888,		TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8) );
PIX_OP_RGBA			( BGR666,	ABGR8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), 255 );
PIX_OP_RGBA			( BGR666,	BGRA4441,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), 1 );
PIX_OP_RGBA			( BGR666,	BGRA4444,	TABLE_SR(6,4), TABLE_SG(6,4), TABLE_SB(6,4), 0x0F );
PIX_OP_RGBA			( BGR666,	BGRA5551,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,5), 1 );
PIX_OP_RGBA			( BGR666,	BGRA8888,	TABLE_SR(6,8), TABLE_SG(6,8), TABLE_SB(6,8), 255 );
PIX_OP_RGB			( BGR666,	RGB332,		TABLE_SR(6,3), TABLE_SG(6,3), TABLE_SB(6,2) );
PIX_OP_RGB			( BGR666,	BGR332,		TABLE_SR(6,2), TABLE_SG(6,3), TABLE_SB(6,3) );
PIX_OP_RGBA			( BGR666,	RGBA5542,	TABLE_SR(6,5), TABLE_SG(6,5), TABLE_SB(6,4), 1 );
PIX_OP_RGBA			( BGR666,	ABGR2554,	TABLE_SR(6,4), TABLE_SG(6,5), TABLE_SB(6,5), 1 );
PIX_OP_RGBA			( BGR666,	RGBA6661,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGBA			( BGR666,	ABGR1666,	SRC_R, SRC_G, SRC_B, 1 );
PIX_OP_RGBA			( BGR666,	RGBA6666,	SRC_R, SRC_G, SRC_B, 0x0F );
PIX_OP_RGBA			( BGR666,	ABGR6666,	SRC_R, SRC_G, SRC_B, 0x0F );
PIX_OP_RGB			( BGR666,	RGB666,		SRC_R, SRC_G, SRC_B );
PIX_CPY				( BGR666 );
PIX_OP_RGBA			( BGR666,	RGBA5658,	TABLE_SR(6,5), SRC_G, TABLE_SB(6,5), 255 );
PIX_OP_RGBA			( BGR666,	ABGR8565,	TABLE_SR(6,5), SRC_G, TABLE_SB(6,5), 255 );
// -- RGBA5658 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( RGBA5658,	RGB444,		TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( RGBA5658,	RGBA4441,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( RGBA5658,	RGBA4444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGB			( RGBA5658,	RGB555,		SRC_R, TABLE_SG(6,5), SRC_B );
PIX_OP_RGBA			( RGBA5658,	RGBA5551,	SRC_R, TABLE_SG(6,5), SRC_B, SRC_A );
PIX_OP_RGB			( RGBA5658,	RGB565,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGB			( RGBA5658,	RGB888,		TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( RGBA5658,	RGBA8888,	TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGB			( RGBA5658,	BGR444,		TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( RGBA5658,	ABGR1444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( RGBA5658,	ABGR4444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGB			( RGBA5658,	BGR555,		SRC_R, TABLE_SG(6,5), SRC_B );
PIX_OP_RGBA			( RGBA5658,	ABGR1555,	SRC_R, TABLE_SG(6,5), SRC_B, SRC_A );
PIX_OP_RGB			( RGBA5658,	BGR565,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGB			( RGBA5658,	BGR888,		TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( RGBA5658,	ABGR8888,	TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGBA			( RGBA5658,	BGRA4441,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( RGBA5658,	BGRA4444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( RGBA5658,	BGRA5551,	SRC_R, TABLE_SG(6,5), SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA5658,	BGRA8888,	TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGB			( RGBA5658,	RGB332,		TABLE_SR(5,3), TABLE_SG(6,3), TABLE_SB(5,2) );
PIX_OP_RGB			( RGBA5658,	BGR332,		TABLE_SR(5,2), TABLE_SG(6,3), TABLE_SB(5,3) );
PIX_OP_RGBA			( RGBA5658,	RGBA5542,	SRC_R, TABLE_SG(6,5), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( RGBA5658,	ABGR2554,	TABLE_SR(5,4), TABLE_SG(6,5), SRC_B, SRC_A );
PIX_OP_RGBA			( RGBA5658,	RGBA6661,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( RGBA5658,	ABGR1666,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( RGBA5658,	RGBA6666,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), TABLE_SA(8,6) );
PIX_OP_RGBA			( RGBA5658,	ABGR6666,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), TABLE_SA(8,6) );
PIX_OP_RGB			( RGBA5658,	RGB666,		TABLE_SR(5,6), SRC_G, TABLE_SB(5,6) );
PIX_OP_RGB			( RGBA5658,	BGR666,		TABLE_SR(5,6), SRC_G, TABLE_SB(5,6) );
PIX_CPY				( RGBA5658 );
PIX_OP_RGBA			( RGBA5658,	ABGR8565,	SRC_R, SRC_G, SRC_B, SRC_A );
// -- ABGR8565 ---------------------------------------------------------------------------------------------
PIX_OP_RGB			( ABGR8565,	RGB444,		TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( ABGR8565,	RGBA4441,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( ABGR8565,	RGBA4444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGB			( ABGR8565,	RGB555,		SRC_R, TABLE_SG(6,5), SRC_B );
PIX_OP_RGBA			( ABGR8565,	RGBA5551,	SRC_R, TABLE_SG(6,5), SRC_B, SRC_A );
PIX_OP_RGB			( ABGR8565,	RGB565,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGB			( ABGR8565,	RGB888,		TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( ABGR8565,	RGBA8888,	TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGB			( ABGR8565,	BGR444,		TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4) );
PIX_OP_RGBA			( ABGR8565,	ABGR1444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( ABGR8565,	ABGR4444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGB			( ABGR8565,	BGR555,		SRC_R, TABLE_SG(6,5), SRC_B );
PIX_OP_RGBA			( ABGR8565,	ABGR1555,	SRC_R, TABLE_SG(6,5), SRC_B, SRC_A );
PIX_OP_RGB			( ABGR8565,	BGR565,		SRC_R, SRC_G, SRC_B );
PIX_OP_RGB			( ABGR8565,	BGR888,		TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8) );
PIX_OP_RGBA			( ABGR8565,	ABGR8888,	TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGBA			( ABGR8565,	BGRA4441,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( ABGR8565,	BGRA4444,	TABLE_SR(5,4), TABLE_SG(6,4), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( ABGR8565,	BGRA5551,	SRC_R, TABLE_SG(6,5), SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR8565,	BGRA8888,	TABLE_SR(5,8), TABLE_SG(6,8), TABLE_SB(5,8), SRC_A );
PIX_OP_RGB			( ABGR8565,	RGB332,		TABLE_SR(5,3), TABLE_SG(6,3), TABLE_SB(5,2) );
PIX_OP_RGB			( ABGR8565,	BGR332,		TABLE_SR(5,2), TABLE_SG(6,3), TABLE_SB(5,3) );
PIX_OP_RGBA			( ABGR8565,	RGBA5542,	SRC_R, TABLE_SG(6,5), TABLE_SB(5,4), SRC_A );
PIX_OP_RGBA			( ABGR8565,	ABGR2554,	TABLE_SR(5,4), TABLE_SG(6,5), SRC_B, SRC_A );
PIX_OP_RGBA			( ABGR8565,	RGBA6661,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( ABGR8565,	ABGR1666,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), SRC_A );
PIX_OP_RGBA			( ABGR8565,	RGBA6666,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), TABLE_SA(8,6) );
PIX_OP_RGBA			( ABGR8565,	ABGR6666,	TABLE_SR(5,6), SRC_G, TABLE_SB(5,6), TABLE_SA(8,6) );
PIX_OP_RGB			( ABGR8565,	RGB666,		TABLE_SR(5,6), SRC_G, TABLE_SB(5,6) );
PIX_OP_RGB			( ABGR8565,	BGR666,		TABLE_SR(5,6), SRC_G, TABLE_SB(5,6) );
PIX_OP_RGBA			( ABGR8565,	RGBA5658,	SRC_R, SRC_G, SRC_B, SRC_A );
PIX_CPY				( ABGR8565 );

// ---------------------------------------------------------------------------------------------------------------------------

void yuv444_to_rgb24( int* r, int* g, int* b, const int y, const int u, const int v )
{
	// convert
	*r = ( ( 1192 * ( y - 16 ) + 1634 * ( v - 128 ) ) >> 10 );
	*g = ( ( 1192 * ( y - 16 ) - 832 * ( v - 128 ) - 400 * ( u - 128 ) ) >> 10 );
	*b = ( ( 1192 * ( y - 16 ) + 2066 * ( u - 128 ) ) >> 10 );
	// clip
	*r = *r < 0 ? 0 : *r > 255 ? 255 : *r; 
	*g = *g < 0 ? 0 : *g > 255 ? 255 : *g;
	*b = *b < 0 ? 0 : *b > 255 ? 255 : *b;
}

ushort yuv444_to_rgb565( const int y, const int u, const int v )
{
	uchar r,g,b;
	// convert
	r = ( ( 1192 * ( y - 16 ) + 1634 * ( v - 128 ) ) >> 10 );
	g = ( ( 1192 * ( y - 16 ) - 832 * ( v - 128 ) - 400 * ( u - 128 ) ) >> 10 );
	b = ( ( 1192 * ( y - 16 ) + 2066 * ( u - 128 ) ) >> 10 );
	// clip
	r = r < 0 ? 0 : r > 255 ? 255 : r; 
	g = g < 0 ? 0 : g > 255 ? 255 : g;
	b = b < 0 ? 0 : b > 255 ? 255 : b;
	ushort p = ( _8bit_to_5bit_table[r] | _8bit_to_6bit_table[g] | _8bit_to_5bit_table[b] );
	return p;
}

ushort yuv444_to_bgr565( const int y, const int u, const int v )
{
	uchar r,g,b;
	// convert
	r = ( ( 1192 * ( y - 16 ) + 1634 * ( v - 128 ) ) >> 10 );
	g = ( ( 1192 * ( y - 16 ) - 832 * ( v - 128 ) - 400 * ( u - 128 ) ) >> 10 );
	b = ( ( 1192 * ( y - 16 ) + 2066 * ( u - 128 ) ) >> 10 );
	// clip
	r = r < 0 ? 0 : r > 255 ? 255 : r; 
	g = g < 0 ? 0 : g > 255 ? 255 : g;
	b = b < 0 ? 0 : b > 255 ? 255 : b;
	ushort p = ( _8bit_to_5bit_table[b] | _8bit_to_6bit_table[g] | _8bit_to_5bit_table[r] );
	return p;
}

void rgb24_to_yuv444( int *y, int *u, int *v, const int r, const int g, const int b )
{
	// convert
	*y = ( ( 263 * r + 516 * g + 100 * b ) >> 10 ) + 16;
	*u = ( ( -152 * r - 298 * g + 450 * b ) >> 10 ) + 128;
	*v = ( ( 450 * r - 377 * g - 73 * b ) >> 10 ) + 128;
}

void* yuv422p_to_rgb_2(uchar* data, const int width, const int height)
{
	uchar *dest = (uchar*)malloc( width * height * 3 );

	int r=0, g=0, b=0;
	uint i, size;
	uchar Y, Y1, U, V;
	uchar *buff		= data;
	uchar *outptr	= dest;

	size = width * height / 2;

	for (i = size; i > 0; i--)
	{
		Y	= buff[0];
		U	= buff[1];
		Y1	= buff[2];
		V	= buff[3];
		buff += 4;

		yuv444_to_rgb24( &r, &g, &b, Y, U, V );

		*outptr++ = r; // R_FROMYV(Y,V);
		*outptr++ = g; // G_FROMYUV(Y,U,V); //b
		*outptr++ = b; // B_FROMYU(Y,U); //v

		yuv444_to_rgb24( &r, &g, &b, Y1, U, V );

		*outptr++ = r; // R_FROMYV(Y1,V);
		*outptr++ = g; // G_FROMYUV(Y1,U,V); //b
		*outptr++ = b; // B_FROMYU(Y1,U); //v
	}

	return (void*)dest;
}

void yuv422p_to_rgb_inline( uchar *data, const int width, const int height )
{
	int h = height;
	int w = width;
	const int r = 0, g = 1, b = 2;
	uchar *dest	= (uchar*)malloc( width * height * 3 );

	int rgb[ 4 ] = { 255, 255, 255, 255 };

	const uchar* src = data;
	int src_pitch = /* width * */ 2;

	uchar* dst = dest;
	int dst_pitch = /* width * */ 3;

	const uchar* sptr = data;
	uchar* dptr = dst;

	int orig_width = width;

	while( h-- )
	{
		while( w > 1 )
		{
			yuv444_to_rgb24( &rgb[ 0 ], &rgb[ 1 ], &rgb[ 2 ], *src, *( src + 1 ), *( src + 3 ) );

			*dst++ = rgb[ r ];
			*dst++ = rgb[ g ];
			*dst++ = rgb[ b ];

			//if ( a != -1 ) *dst ++ = rgb[ a ];

			src += 2;

			yuv444_to_rgb24( &rgb[ 0 ], &rgb[ 1 ], &rgb[ 2 ], *src, *( src - 1 ), *( src + 1 ) );

			*dst++ = rgb[ r ];
			*dst++ = rgb[ g ];
			*dst++ = rgb[ b ];

			//if ( a != -1 ) *dst ++ = rgb[ a ];

			src += 2;
			w -= 2;
		}

		dst = dptr += dst_pitch;
		src = sptr += src_pitch;

		w = orig_width;
	}

	fast_memcpy( data, dest, width * height * 3 );

	free( dest );
}

void yuv422p_to_rgb( uchar *data, uchar *dest, const int width, const int height )
{
	int h = height;
	int w = width;
	const int r = 0, g = 1, b = 2;
	int rgb[ 4 ] = { 255, 255, 255, 255 };

	const uchar* src = data;
	int src_pitch = /* width * */ 2;

	uchar* dst = dest;
	int dst_pitch = /* width * */ 3;

	const uchar* sptr = data;
	uchar* dptr = dst;

	int orig_width = width;

	while( h -- )
	{
		while( w > 1 )
		{
			yuv444_to_rgb24( &rgb[ 0 ], &rgb[ 1 ], &rgb[ 2 ], *src, *( src + 1 ), *( src + 3 ) );

			*dst++ = rgb[ r ];
			*dst++ = rgb[ g ];
			*dst++ = rgb[ b ];

			//if ( a != -1 ) *dst ++ = rgb[ a ];

			src += 2;

			yuv444_to_rgb24( &rgb[ 0 ], &rgb[ 1 ], &rgb[ 2 ], *src, *( src - 1 ), *( src + 1 ) );

			*dst++ = rgb[ r ];
			*dst++ = rgb[ g ];
			*dst++ = rgb[ b ];

			//if ( a != -1 ) *dst ++ = rgb[ a ];

			src += 2;
			w -= 2;
		}

		dst = dptr += dst_pitch;
		src = sptr += src_pitch;

		w = orig_width;
	}
}

void yuv422p_to_rgb565( uchar *src, uchar *dest, const int width, const int height )
{
	uint i;
	uint pix_len = width * height;
	const uchar *ysrc = src;
	const uchar *usrc = src + 1;
	const uchar *vsrc = src + 3;

	ushort* dst = (ushort*)dest;

	for (i = 0; i < pix_len; i += 2)
	{
		int u1 = (((*usrc - 128) << 7) +  (*usrc - 128)) >> 6;
		int rg = (((*usrc - 128) << 1) +  (*usrc - 128) + 
					((*vsrc - 128) << 2) + ((*vsrc - 128) << 1)) >> 3;
		int v1 = (((*vsrc - 128) << 1) +  (*vsrc - 128)) >> 1;

		uchar r = CLIP(*ysrc + u1);
		uchar g = CLIP(*ysrc - rg);
		uchar b = CLIP(*ysrc + v1);

		*dst++ = PACK_PIXEL_RGB565(r,g,b);

		ysrc += 2;

		r = CLIP(*ysrc + u1);
		g = CLIP(*ysrc - rg);
		b = CLIP(*ysrc + v1);

		*dst++ = PACK_PIXEL_RGB565(r,g,b);

		ysrc += 2;
		usrc += 4;
		vsrc += 4;
	}
}

void yuv422p_to_bgr565( uchar *src, uchar *dest, const int width, const int height )
{
	//static int dump = 1;
	uint i;
	uint pix_len = width * height;
	const uchar *ysrc = src;
	const uchar *usrc = src + 1;
	const uchar *vsrc = src + 3;

	ushort* dst = (ushort*)dest;

	for (i = 0; i < pix_len; i += 2)
	{
		const int u1 = (((*usrc - 128) << 7) +  (*usrc - 128)) >> 6;

		const int rg = (((*usrc - 128) << 1) +  (*usrc - 128) + 
						((*vsrc - 128) << 2) + ((*vsrc - 128) << 1)) >> 3;

		const int v1 = (((*vsrc - 128) << 1) +  (*vsrc - 128)) >> 1;

		uchar r = CLIP(*ysrc + u1);
		uchar g = CLIP(*ysrc - rg);
		uchar b = CLIP(*ysrc + v1);

		//if ( dump ) printf( "0x%X,0x%X,0x%X\n", r,g,b );

		*dst++ = PACK_PIXEL_RGB565(b,g,r);

		ysrc += 2;

		r = CLIP(*ysrc + u1);
		g = CLIP(*ysrc - rg);
		b = CLIP(*ysrc + v1);

		*dst++ = PACK_PIXEL_RGB565(b,g,r);

		ysrc += 2;
		usrc += 4;
		vsrc += 4;
	}
	//dump = 0;
}

void* yuv422_to_rgb_2( uchar *data, const int width, const int height )
{
	int h = height;
	int w = width;
	const int r = 0, g = 1, b = 2;
	uchar *dest = (uchar *)malloc(width * height * 3);

	int rgb[ 4 ] = { 255, 255, 255, 255 };

	const uchar* src = data;
	int src_pitch = /* width * */ 2;

	uchar* dst = dest;
	int dst_pitch = /* width * */ 3;

	const uchar* sptr = data;
	uchar* dptr = dst;

	int orig_width = width;

	while( h -- )
	{
		while( w > 1 )
		{
			yuv444_to_rgb24( &rgb[ 0 ], &rgb[ 1 ], &rgb[ 2 ], *src, *( src + 1 ), *( src + 3 ) );

			*dst++ = rgb[ r ];
			*dst++ = rgb[ g ];
			*dst++ = rgb[ b ];

			//if ( a != -1 ) *dst ++ = rgb[ a ];

			src += 2;

			yuv444_to_rgb24( &rgb[ 0 ], &rgb[ 1 ], &rgb[ 2 ], *src, *( src - 1 ), *( src + 1 ) );

			*dst++ = rgb[ r ];
			*dst++ = rgb[ g ];
			*dst++ = rgb[ b ];

			//if ( a != -1 ) *dst ++ = rgb[ a ];

			src += 2;
			w -= 2;
		}

		dst = dptr += dst_pitch;
		src = sptr += src_pitch;

		w = orig_width;
	}

	return (void*)dest;
}

void yuv422_to_rgb( uchar *data, uchar* dest, const int width, const int height )
{
	int h = height;
	int w = width;
	const ushort r = 0, g = 1, b = 2;
	//float *dest = (float*)malloc( width * height * 3 * sizeof(float) );

	int rgb[ 4 ] = { 255, 255, 255, 255 };

	const uchar* src = data;
	int src_pitch = /* width * */ 2;

	uchar* dst = dest;
	int dst_pitch = /* width * */ 3;

	const uchar* sptr = data;
	uchar* dptr = dst;

	int orig_width = width;

	while( h -- )
	{
		while( w > 1 )
		{
			yuv444_to_rgb24( &rgb[ 0 ], &rgb[ 1 ], &rgb[ 2 ], *src, *( src + 1 ), *( src + 3 ) );

			*dst++ = rgb[ r ];
			*dst++ = rgb[ g ];
			*dst++ = rgb[ b ];

			//if ( a != -1 ) *dst ++ = rgb[ a ];

			src += 2;

			yuv444_to_rgb24( &rgb[ 0 ], &rgb[ 1 ], &rgb[ 2 ], *src, *( src - 1 ), *( src + 1 ) );

			*dst++ = rgb[ r ];
			*dst++ = rgb[ g ];
			*dst++ = rgb[ b ];

			//if ( a != -1 ) *dst ++ = rgb[ a ];

			src += 2;
			w -= 2;
		}

		dst = dptr += dst_pitch;
		src = sptr += src_pitch;

		w = orig_width;
	}

	//return (void*)dest;
}

// YUV420 aka YV12
void* yv12_to_422p_2( uchar *input, const int width, const int height )
{
	uchar *dest = (uchar*)malloc( width * height * 3 );
	int row, col;
	uchar *u, *_u, *v, *_v;

	/* copy Y' */
	fast_memcpy(dest, input, width * height);

	/* copy the data we've got */

	v = dest + width * height;
	u = dest + width * height * 3 / 2;

	_v = input + width * height;
	_u = input + width * height * 5 / 4;

	for (row = 0; row < height / 2; ++row)
	{
		for (col = 0; col < width / 2; ++col)
		{
			*v = *_v;
			*u = *_u;

			/* duplicate each U & V line */
			/* FIXME: causes flicker sometimes */
			*(v + width / 2) = *_v++;
			*(u + width / 2) = *_u++;

			u++;
			v++;
		}
		v += width / 2;
		u += width / 2 ;
	}

	return (void*)dest;
}

void yv12_to_422p(uchar *src, uchar* dest, const int width, const int height)
{
	int row, col;
	uchar *u, *_u, *v, *_v;

	/* copy Y' */
	fast_memcpy(dest, src, width * height);

	/* copy the data we've got */

	v = dest + width * height;
	u = dest + width * height * 3 / 2;

	_v = src + width * height;
	_u = src + width * height * 5 / 4;

	for (row = 0; row < height / 2; ++row)
	{
		for (col = 0; col < width / 2; ++col)
		{
			*v = *_v;
			*u = *_u;

			/* duplicate each U & V line */
			/* FIXME: causes flicker sometimes */
			*(v + width / 2) = *_v++;
			*(u + width / 2) = *_u++;

			u++;
			v++;
		}
		v += width / 2;
		u += width / 2 ;
	}
}

// YUV420 aka YV12
void* yuv420_to_yuv422p(uchar *input, const int width, const int height)
{
	return yv12_to_422p_2(input, width, height );
}

void* yuv420_to_rgb_2(uchar *input, const int width, const int height)
{
	void* data = yv12_to_422p_2(input, width, height );

	yuv422p_to_rgb_inline( (uchar*)data, width, height );

	return data;
}

void yuv420_to_rgb_inline( uchar *input, const int width, const int height )
{
	//uchar* data = (uchar*)yv12_to_422p(input, width, height );
	uchar* dest = (uchar*)malloc( width * height * 3 );

	yv12_to_422p( input, dest, width, height );

	yuv422p_to_rgb_2( dest, width, height );

	fast_memcpy( input, dest, width * height * 3 );
	
	free( dest );
}

void yuv420_to_rgb( uchar *src, uchar* dest, const int width, const int height )
{
	uchar* temp = (uchar*)malloc( width * height * 3 );

	yv12_to_422p( src, temp, width, height );

	yuv422p_to_rgb( temp, dest, width, height );

	free( temp );
}

void yuv420_to_rgb565( uchar *src, uchar* dest, const int width, const int height )
{
	uchar* temp = (uchar*)malloc( width * height * 3 );

	yv12_to_422p( src, temp, width, height );

	yuv422p_to_rgb565( temp, dest, width, height );

	free( temp );
}

void yuv420_to_bgr565( uchar *src, uchar* dest, const int width, const int height )
{
	uchar* temp = (uchar*)malloc( width * height * 3 );

	yv12_to_422p( src, temp, width, height );

	yuv422p_to_bgr565( temp, dest, width, height );

	free( temp );
}

void yuv422_to_rgb_inline( uchar *input, const int width, const int height )
{
	uchar* data = (uchar*)uyvy_to_422p_2(input, width, height );

	yuv422p_to_rgb_inline( data, width, height );

	fast_memcpy( input, data, width * height * 3 );

	free( data );
}

void yuv422_to_rgb565( uchar *src, uchar* dest, const int width, const int height )
{
	const uint size = width * height * 3;
	uchar* temp = (uchar*)malloc( size );
	uyvy_to_422p( src, temp, width, height );
	yuv422p_to_rgb565( temp, dest, width, height );
	free( temp );
}

void yuv422_to_bgr565( uchar *src, uchar* dest, const int width, const int height )
{
	yuv422p_to_bgr565( src, dest, width, height );
}

// YUV 4:2:2 uyvy
void* uyvy_to_422p_2(uchar *input, const int width, const int height)
{
	uchar *dest = (uchar*)malloc( width * height * 3 );
	int i, j;
	uchar *y, *u, *v;

	y = dest;
	v = dest + width * height;
	u = dest + width * height * 3 / 2;

	for (i = 0; i < height; i++)
	{
		for (j = 0; j < width / 2; ++j)
		{
			/* UYVY.  The byte order is CbY'CrY' */
			*u++ = *input++;
			*y++ = *input++;
			*v++ = *input++;
			*y++ = *input++;
		}
	}

	return (void*)dest;
}

void uyvy_to_422p(uchar *input, uchar* dest, const int width, const int height) 
{
	int i, j;
	uchar *y, *u, *v;

	y = dest;
	v = dest + width * height;
	u = dest + width * height * 3 / 2;

	for (i = 0; i < height; i++)
	{
		for (j = 0; j < width / 2; ++j)
		{
			/* UYVY.  The byte order is CbY'CrY' */
			*u++ = *input++;
			*y++ = *input++;
			*v++ = *input++;
			*y++ = *input++;
		}
	}
}

// YUV 4:2:2 (aka uyvy) to YUV420 (aka yv12)
void*  uyvy_to_yv12(uchar *input, const int width, const int height)
{
	uchar *dest = (uchar*)malloc( width * height * 3 );
	int i, j, w2;
	uchar *y, *u, *v;

	w2 = width / 2;

	/* I420 */
	y = dest;
	v = dest + width * height;
	u = dest + width * height * 5 / 4;

	for (i = 0; i < height; i += 2)
	{
		for (j = 0; j < w2; ++j)
		{
			/* UYVY.  The byte order is CbY'CrY' */
			*u++ = *input++;
			*y++ = *input++;
			*v++ = *input++;
			*y++ = *input++;
		}

		/* down sampling */
		u -= w2;
		v -= w2;

		/* average every second line for U and V */
		for (j = 0; j < w2; ++j)
		{
			int un = *u & 0xff;
			int vn = *v & 0xff; 

			un += *input++ & 0xff;
			*u++ = un>>1;

			*y++ = *input++;

			vn += *input++ & 0xff;
			*v++ = vn>>1;

			*y++ = *input++;
		}
	}

	return (void*)dest;
}

// ---------------------------------------------------------------------------------------------------------

void* rgb24_to_rgb5551(uchar *data, const int width, const int height)
{
	struct PIXEL_RGBA5551* dest = (struct PIXEL_RGBA5551*)malloc( width * height * sizeof(struct PIXEL_RGBA5551) );

	RGB888_to_RGBA5551( data, dest, width, height );

	return (void*)dest;
}

void* rgb32_to_rgb5551(uchar *data, const int width, const int height)
{
	struct PIXEL_RGBA5551* dest = (struct PIXEL_RGBA5551*)malloc( width * height * sizeof(struct PIXEL_RGBA5551) );

	RGBA8888_to_RGBA5551( data, dest, width, height );

	return (void*)dest;
}

void* rgb24_to_rgb4444(uchar *data, const int width, const int height)
{
	struct PIXEL_RGBA4444* dest = (struct PIXEL_RGBA4444*)malloc( width * height * sizeof(struct PIXEL_RGBA4444) );

	RGB888_to_RGBA4444( data, dest, width, height );

	return (void*)dest;
}

void* rgb32_to_rgb4444(uchar *data, const int width, const int height)
{
	struct PIXEL_RGBA4444* dest = (struct PIXEL_RGBA4444*)malloc( width * height * sizeof(struct PIXEL_RGBA4444) );

	RGBA8888_to_RGBA4444( data, dest, width, height );

	return (void*)dest;
}

void* rgb32_to_rgb565(uchar *data, const int width, const int height)
{
	struct PIXEL_RGB565* dest = (struct PIXEL_RGB565*)malloc( width * height * sizeof(struct PIXEL_RGB565) );

	RGBA8888_to_RGB565( data, dest, width, height );

	return (void*)dest;
}

void* rgb32_to_bgr565_2(uchar *data, const int width, const int height)
{
	struct PIXEL_BGR565* dest = (struct PIXEL_BGR565*)malloc( width * height * sizeof(struct PIXEL_BGR565) );

	RGBA8888_to_BGR565( data, dest, width, height );

	return (void*)dest;
}

void rgb32_to_bgr565(uchar *data, uchar* dest, const int width, const int height)
{
	RGBA8888_to_BGR565( data, (struct PIXEL_BGR565*)dest, width, height );
}

void* rgb24_to_rgb565_2(uchar *data, const int width, const int height)
{
	struct PIXEL_RGB565* dest = (struct PIXEL_RGB565*)malloc( width * height * sizeof(struct PIXEL_RGB565) );

	RGB888_to_RGB565( data, dest, width, height );

	return (void*)dest;
}

void rgb24_to_rgb565(uchar *data, uchar* dest, const int width, const int height)
{
	RGB888_to_RGB565( data, (struct PIXEL_RGB565*)dest, width, height );
}

void rgb24_to_bgr565(uchar *data, uchar* dest, const int width, const int height)
{
	RGB888_to_BGR565( data, (struct PIXEL_BGR565*)dest, width, height );
}

void* rgb565_to_rgb888(ushort *data, const int width, const int height)
{
	struct PIXEL_RGB888* dest = (struct PIXEL_RGB888*)malloc( width * height * sizeof(struct PIXEL_RGB888) );

	RGB565_to_RGB888( data, dest, width, height );

	return (void*)dest;
}

// ---------------------------------------------------------------------------------------------------------

void* rgba_float2rgba(float *data,const int width,const int height)
{
	uchar *dest = (uchar*)malloc(width * height * 4);
	uchar *d = dest;
	float *s = data;
	int i;

	for ( i = 0; i < width * height; ++i )
	{
		*d++ = (uchar)(*s++) * 255.0f;
		*d++ = (uchar)(*s++) * 255.0f;
		*d++ = (uchar)(*s++) * 255.0f;
		*d++ = (uchar)(*s++) * 255.0f;
	}

	return (void*)dest;
}

void* rgb2rgba(uchar *data,const int width,const int height)
{
	uchar *dest = ( uchar*)malloc(width * height * 4);
	uchar *d = dest;
	uchar *s = data;
	int i;

	for ( i = 0; i < width * height; ++i )
	{
		*d++ = *s++;
		*d++ = *s++;
		*d++ = *s++;
		*d++ = 255;
	}

	return (void*)dest;
}

void* rgba2rgb(uchar *data,const int width,const int height)
{
	uchar *dest = (uchar*)malloc(width * height * 3);
	uchar *d = dest;
	uchar *s = data;
	int i;

	for ( i = 0; i < width * height; ++i )
	{
		*d++ = *s++;
		*d++ = *s++;
		*d++ = *s++;
		s++;
	}

	return (void*)dest;
}

void rgba2rgb_inline( uchar *data, const int width, const int height )
{
	uchar *dest	= (uchar*)malloc( width * height * 3 );

	uchar *d = dest;
	uchar *s = data;
	int i;

	for ( i = 0; i < width * height; ++i )
	{
		*d++ = *s++;
		*d++ = *s++;
		*d++ = *s++;
		s++;
	}

	fast_memcpy( data, dest, width * height * 3 );

	free( dest );
}

void* rgba2rgba(uchar *data,const int width,const int height)
{
	uchar *dest = (uchar*)malloc(width * height * 4);
	uchar *d = dest;
	uchar *s = data;
	int i;

	for ( i = 0; i < width * height; ++i)
	{
		*d++ = *s++;
		*d++ = *s++;
		*d++ = *s++;
		*d++ = *s++;
	}

	return (void*)dest;
}

void* rgba2luminance_float(uchar *data,const int width,const int height)
{
	float *dest = (float*)malloc( width * height * sizeof(float) );
	float *d = dest;
	uchar *s = data;
	int i;

	for ( i = 0; i < width * height; ++i)
	{
		*d++ = (float)(*s++) / 255.0f;
		s += 3;
	}

	return (void*)dest;
}

void* rgba2luminance_alpha_float(uchar *data,const int width,const int height)
{
	float *dest = (float*)malloc( width * height * 2 * sizeof(float) );
	float *d = dest;
	uchar *s = data;
	int i;

	for ( i = 0; i < width * height; ++i)
	{
		*d++ = (float)(*s++) / 255.0f;
		s += 2;
		*d++ = (float)(*s++) / 255.0f;
	}

	return (void*)dest;
}

void* rgba2rgb_float(uchar *data,const int width,const int height)
{
	float *dest = (float*)malloc( width * height * 3 * sizeof(float) );
	float *d = dest;
	uchar *s = data;
	int i;

	for ( i = 0; i < width * height; ++i)
	{
		*d++ = (float)(*s++) / 255.0f;
		*d++ = (float)(*s++) / 255.0f;
		*d++ = (float)(*s++) / 255.0f;
		s++;
	}

	return (void*)dest;
}

void* rgba2rgba_float(uchar *data,const int width,const int height)
{
	float *dest = (float*)malloc( width * height * 4 * sizeof(float) );
	float *d = dest;
	uchar *s = data;
	int i;

	for ( i = 0; i < width * height; ++i)
	{
		*d++ = (float)(*s++) / 255.0f;
		*d++ = (float)(*s++) / 255.0f;
		*d++ = (float)(*s++) / 255.0f;
		*d++ = (float)(*s++) / 255.0f;
	}

	return (void*)dest;
}

void* rgb_float2rgb(float *data,const int width,const int height)
{
	float *dest = (float*)malloc( width * height * 3 * sizeof(float) );
	uchar *d = (uchar*)dest;
	float *s = data;
	int i;

	for ( i = 0; i < width * height; ++i)
	{
		*d++ = (uchar)(*s++) * 255.0f;
		*d++ = (uchar)(*s++) * 255.0f;
		*d++ = (uchar)(*s++) * 255.0f;
	}

	return (void*)dest;
}

void* rgba_float2rgb(float *data,const int width,const int height)
{
	float *dest = (float*)malloc( width * height * 3 * sizeof(float) );
	uchar *d = (uchar*)dest;
	float *s = data;
	int i;

	for ( i = 0; i < width * height; ++i)
	{
		*d++ = (uchar)(*s++) * 255.0f;
		*d++ = (uchar)(*s++) * 255.0f;
		*d++ = (uchar)(*s++) * 255.0f;
		(void)*s++;
	}

	return (void*)dest;
}

void* rgba2luminance(uchar *data,const int width,const int height)
{
	uchar *dest = (uchar*)malloc( width * height );
	fast_memset(dest, 0x00, width * height);

	uchar *d = dest;
	uchar *s = data;
	int i;

	for ( i = 0; i < width * height; ++i)
	{
		*d++ = *s++;
		s += 3;
	}

	return (void*)dest;
}

void* luminance2rgba(uchar *data,const int width,const int height)
{
	uchar *dest = (uchar*)malloc( width * height * 4);
	fast_memset(dest, 0x00, width * height * 4);

	uchar *d = dest;
	uchar *s = data;
	int i;

	for ( i = 0; i < width * height; ++i)
	{
		*d++ = *s++;
		d += 3;
	}

	return (void*)dest;
}

void* rgba2luminance_alpha(uchar *data,const int width,const int height)
{
	uchar *dest = (uchar*)malloc( width * height * 2);
	fast_memset(dest, 0x00, width * height * 2);
	uchar *d = dest;
	uchar *s = data;
	int i;

	for ( i = 0; i < width * height; ++i)
	{
		*d++ = *s++;
		s += 2;
		*d++ = *s++;
	}

	return (void*)dest;
}

// ----------------------------------------------------------------------------------------------

void rgb24_to_yuv420p( const uchar * rgb, uchar * yuv, const uint rgbIncrement, const uchar flip, const int srcFrameWidth, const int srcFrameHeight )
{
	#define rgbtoy(b, g, r, y) \
		y=(uchar)(((int)(30*r) + (int)(59*g) + (int)(11*b))/100)

	#define rgbtoyuv(b, g, r, y, u, v) \
		rgbtoy(b, g, r, y); \
		u=(uchar)(((int)(-17*r) - (int)(33*g) + (int)(50*b)+12800)/100); \
		v=(uchar)(((int)(50*r) - (int)(42*g) - (int)(8*b)+12800)/100)

	uint planeSize;
	uint halfWidth;

	uchar * yplane;
	uchar * uplane;
	uchar * vplane;
	const uchar * rgbIndex;

	int x, y;
	uchar * yline;
	uchar * uline;
	uchar * vline;

	planeSize = srcFrameWidth * srcFrameHeight;
	halfWidth = srcFrameWidth >> 1;

	// get pointers to the data
	yplane = yuv;
	uplane = yuv + planeSize;
	vplane = yuv + planeSize + (planeSize >> 2);
	rgbIndex = rgb;

	for (y = 0; y < srcFrameHeight; ++y)
	{
		yline = yplane + (y * srcFrameWidth);
		uline = uplane + ((y >> 1) * halfWidth);
		vline = vplane + ((y >> 1) * halfWidth);

		if (flip)
			rgbIndex = rgb + (srcFrameWidth*(srcFrameHeight-1-y)*rgbIncrement);

		for (x = 0; x < (int) srcFrameWidth; x+=2)
		{
			rgbtoyuv(rgbIndex[0], rgbIndex[1], rgbIndex[2], *yline, *uline, *vline);
			rgbIndex += rgbIncrement;
			yline++;
			rgbtoyuv(rgbIndex[0], rgbIndex[1], rgbIndex[2], *yline, *uline, *vline);
			rgbIndex += rgbIncrement;
			yline++;
			uline++;
			vline++;
		}
	}
	#undef rgbtoy
	#undef rgbtoyuv
}

const char* Fmt2Str( const int type )
{
	#define CHK_TYPE(x)	case x : return #x;

	switch( type )
	{
		CHK_TYPE( RGB444  );
		CHK_TYPE( RGBA4441 );
		CHK_TYPE( RGBA4444 );
		CHK_TYPE( RGB555  );
		CHK_TYPE( RGBA5551 );
		CHK_TYPE( RGB565  );
		CHK_TYPE( RGB888  );
		CHK_TYPE( RGBA8888 );
		CHK_TYPE( BGR444  );
		CHK_TYPE( ABGR1444 );
		CHK_TYPE( ABGR4444 );
		CHK_TYPE( BGR555  );
		CHK_TYPE( ABGR1555 );
		CHK_TYPE( BGR565  );
		CHK_TYPE( BGR888  );
		CHK_TYPE( ABGR8888 );
		CHK_TYPE( BGRA4441 );
		CHK_TYPE( BGRA4444 );
		CHK_TYPE( BGRA5551 );
		CHK_TYPE( BGRA8888 );
		CHK_TYPE( RGB332 );
		CHK_TYPE( BGR332 );
		CHK_TYPE( RGBA5542 );
		CHK_TYPE( ABGR2554 );
		CHK_TYPE( RGBA6661 );
		CHK_TYPE( ABGR1666 );
		CHK_TYPE( RGBA6666 );
		CHK_TYPE( ABGR6666 );
		CHK_TYPE( RGB666 );
		CHK_TYPE( BGR666 );
		CHK_TYPE( RGBA5658 );
		CHK_TYPE( ABGR8565 );
		CHK_TYPE( YV12 );
		CHK_TYPE( I420 );
		CHK_TYPE( NV12 );
		CHK_TYPE( Y41P );
		CHK_TYPE( Y411 );
		CHK_TYPE( YUY2 );
		CHK_TYPE( UYVY );
	}

	#undef CHK_TYPE
	return "unknown";
}

#define PROTO_FNC(name) \
 void  name ## _to_RGB444	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_RGBA4441	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_RGBA4444	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_RGB555	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_RGBA5551	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_RGB565	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_RGB888	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_RGBA8888	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_BGR444	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_ABGR1444	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_ABGR4444	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_BGR555	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_ABGR1555	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_BGR565	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_BGR888	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_ABGR8888	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_BGRA4441	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_BGRA4444	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_BGRA5551	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_BGRA8888	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_RGB332	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_BGR332	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_RGBA5542	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_ABGR2554	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_RGBA6661	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_ABGR1666	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_RGBA6666	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_ABGR6666	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_RGB666	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_BGR666	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_RGBA5658	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_ABGR8565	(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");}

#define PROTO_FNC2(name) \
 void  name ## _to_YV12 		(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_I420 		(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_NV12 		(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_Y41P 		(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_Y411 		(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_YUY2 		(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");} \
 void  name ## _to_UYVY 		(void *bsrc,void *bdst,const int width,const int height) {TRACE_DEBUG("Function  not implemented");}

PROTO_FNC2( RGB444 );
PROTO_FNC2( RGBA4441 );
PROTO_FNC2( RGBA4444 );
PROTO_FNC2( RGB555 );
PROTO_FNC2( RGBA5551 );
PROTO_FNC2( RGB565 );
PROTO_FNC2( RGB888 );
PROTO_FNC2( RGBA8888 );
PROTO_FNC2( BGR444 );
PROTO_FNC2( ABGR1444 );
PROTO_FNC2( ABGR4444 );
PROTO_FNC2( BGR555 );
PROTO_FNC2( ABGR1555 );
PROTO_FNC2( BGR565 );
PROTO_FNC2( BGR888 );
PROTO_FNC2( ABGR8888 );
PROTO_FNC2( BGRA4441 );
PROTO_FNC2( BGRA4444 );
PROTO_FNC2( BGRA5551 );
PROTO_FNC2( BGRA8888 );
PROTO_FNC2( RGB332 );
PROTO_FNC2( BGR332 );
PROTO_FNC2( RGBA5542 );
PROTO_FNC2( ABGR2554 );
PROTO_FNC2( RGBA6661 );
PROTO_FNC2( ABGR1666 );
PROTO_FNC2( RGBA6666 );
PROTO_FNC2( ABGR6666 );
PROTO_FNC2( RGB666 );
PROTO_FNC2( BGR666 );
PROTO_FNC2( RGBA5658 );
PROTO_FNC2( ABGR8565 );

PROTO_FNC2( YV12 );
PROTO_FNC2( I420 );
PROTO_FNC2( NV12 );
PROTO_FNC2( Y41P );
PROTO_FNC2( Y411 );
PROTO_FNC2( YUY2 );
PROTO_FNC2( UYVY );

PROTO_FNC( YV12 );
PROTO_FNC( I420 );
PROTO_FNC( NV12 );
PROTO_FNC( Y41P );
PROTO_FNC( Y411 );
PROTO_FNC( YUY2 );
//PROTO_FNC( UYVY );

void UYVY_to_RGB565(void *src,void *dest,const int width,const int height)
{
	uint i;
	const uint pix_len = width * height;
	const uchar *ysrc = (const uchar*)src;
	const uchar *usrc = (const uchar*)src + 1;
	const uchar *vsrc = (const uchar*)src + 3;

	ushort* dst = (ushort*)dest;

	for (i = 0; i < pix_len; i += 2)
	{
		const int u1 = (((*usrc - 128) << 7) +  (*usrc - 128)) >> 6;
		const int rg = (((*usrc - 128) << 1) +  (*usrc - 128) + 
						((*vsrc - 128) << 2) + ((*vsrc - 128) << 1)) >> 3;
		const int v1 = (((*vsrc - 128) << 1) +  (*vsrc - 128)) >> 1;

		uchar r = CLIP(*ysrc + u1);
		uchar g = CLIP(*ysrc - rg);
		uchar b = CLIP(*ysrc + v1);

		*dst++ = PACK_PIXEL_RGB565(r,g,b);

		ysrc += 2;

		r = CLIP(*ysrc + u1);
		g = CLIP(*ysrc - rg);
		b = CLIP(*ysrc + v1);

		*dst++ = PACK_PIXEL_RGB565(r,g,b);

		ysrc += 2;
		usrc += 4;
		vsrc += 4;
	}
}

// yuv422p_to_bgr565
void UYVY_to_BGR565(void *src,void *dest,const int width,const int height)
{
	uint i;
	const uint pix_len = width * height;
	const uchar *ysrc = (const uchar*)src;
	const uchar *usrc = (const uchar*)src + 1;
	const uchar *vsrc = (const uchar*)src + 3;

	ushort* dst = (ushort*)dest;

	for (i = 0; i < pix_len; i += 2)
	{
		const int u1 = (((*usrc - 128) << 7) +  (*usrc - 128)) >> 6;
		const int rg = (((*usrc - 128) << 1) +  (*usrc - 128) + 
						((*vsrc - 128) << 2) + ((*vsrc - 128) << 1)) >> 3;
		const int v1 = (((*vsrc - 128) << 1) +  (*vsrc - 128)) >> 1;

		uchar r = CLIP(*ysrc + u1);
		uchar g = CLIP(*ysrc - rg);
		uchar b = CLIP(*ysrc + v1);

		*dst++ = PACK_PIXEL_RGB565(b,g,r);

		ysrc += 2;

		r = CLIP(*ysrc + u1);
		g = CLIP(*ysrc - rg);
		b = CLIP(*ysrc + v1);

		*dst++ = PACK_PIXEL_RGB565(b,g,r);

		ysrc += 2;
		usrc += 4;
		vsrc += 4;
	}
}

void UYVY_to_RGBA8888(void *src,void *dst,const int width,const int height)
{
	uint i;
	const uint pix_len = width * height;
	const uchar *ysrc = (const uchar*)src;
	const uchar *usrc = (const uchar*)src + 1;
	const uchar *vsrc = (const uchar*)src + 3;
	uchar *dest = (uchar*)dst;

	for (i = 0; i < pix_len; i += 2)
	{
		const int u1 = (((*usrc - 128) << 7) +  (*usrc - 128)) >> 6;
		const int rg = (((*usrc - 128) << 1) +  (*usrc - 128) + 
						((*vsrc - 128) << 2) + ((*vsrc - 128) << 1)) >> 3;
		const int v1 = (((*vsrc - 128) << 1) +  (*vsrc - 128)) >> 1;

		*dest++ = CLIP(*ysrc + u1);
		*dest++ = CLIP(*ysrc - rg);
		*dest++ = CLIP(*ysrc + v1);
		*dest++ = 0;

		ysrc += 2;

		*dest++ = CLIP(*ysrc + u1); 
		*dest++ = CLIP(*ysrc - rg);
		*dest++ = CLIP(*ysrc + v1); 
		*dest++ = 0;

		ysrc += 2;
		usrc += 4;
		vsrc += 4;
	}
}

void UYVY_to_BGRA8888(void *src,void *dst,const int width,const int height)
{
	uint i;
	const uint pix_len = width * height;
	const uchar *ysrc = (const uchar*)src;
	const uchar *usrc = (const uchar*)src + 1;
	const uchar *vsrc = (const uchar*)src + 3;
	uchar *dest = (uchar*)dst;

	for (i = 0; i < pix_len; i += 2)
	{
		const int u1 = (((*usrc - 128) << 7) +  (*usrc - 128)) >> 6;
		const int rg = (((*usrc - 128) << 1) +  (*usrc - 128) + 
						((*vsrc - 128) << 2) + ((*vsrc - 128) << 1)) >> 3;
		const int v1 = (((*vsrc - 128) << 1) +  (*vsrc - 128)) >> 1;

		*dest++ = CLIP(*ysrc + v1);	// b
		*dest++ = CLIP(*ysrc - rg);	// g
		*dest++ = CLIP(*ysrc + u1);	// r
		*dest++ = 0;

		ysrc += 2;

		*dest++ = CLIP(*ysrc + v1);	// b
		*dest++ = CLIP(*ysrc - rg);	// g
		*dest++ = CLIP(*ysrc + u1);	// r
		*dest++ = 0;

		ysrc += 2;
		usrc += 4;
		vsrc += 4;
	}
}

void UYVY_to_ABGR8888(void *src,void *dst,const int width,const int height)
{
	uint i;
	const uint pix_len = width * height;
	const uchar *ysrc = (const uchar*)src;
	const uchar *usrc = (const uchar*)src + 1;
	const uchar *vsrc = (const uchar*)src + 3;
	uchar *dest = (uchar*)dst;

	for (i = 0; i < pix_len; i += 2)
	{
		const int u1 = (((*usrc - 128) << 7) +  (*usrc - 128)) >> 6;
		const int rg = (((*usrc - 128) << 1) +  (*usrc - 128) + 
						((*vsrc - 128) << 2) + ((*vsrc - 128) << 1)) >> 3;
		const int v1 = (((*vsrc - 128) << 1) +  (*vsrc - 128)) >> 1;

		*dest++ = 0;
		*dest++ = CLIP(*ysrc + v1);	// b
		*dest++ = CLIP(*ysrc - rg);	// g
		*dest++ = CLIP(*ysrc + u1);	// r

		ysrc += 2;

		*dest++ = 0;
		*dest++ = CLIP(*ysrc + v1);	// b
		*dest++ = CLIP(*ysrc - rg);	// g
		*dest++ = CLIP(*ysrc + u1);	// r

		ysrc += 2;
		usrc += 4;
		vsrc += 4;
	}
}

void UYVY_to_RGB888(void *src,void *dst,const int width,const int height)
{
	uint i;
	const uint pix_len = width * height;
	const uchar *ysrc = (const uchar*)src;
	const uchar *usrc = (const uchar*)src + 1;
	const uchar *vsrc = (const uchar*)src + 3;
	uchar *dest = (uchar*)dst;

	for (i = 0; i < pix_len; i += 2)
	{
		const int u1 = (((*usrc - 128) << 7) +  (*usrc - 128)) >> 6;
		const int rg = (((*usrc - 128) << 1) +  (*usrc - 128) + 
						((*vsrc - 128) << 2) + ((*vsrc - 128) << 1)) >> 3;
		const int v1 = (((*vsrc - 128) << 1) +  (*vsrc - 128)) >> 1;

		*dest++ = CLIP(*ysrc + u1);	// r
		*dest++ = CLIP(*ysrc - rg);	// g
		*dest++ = CLIP(*ysrc + v1);	// b
		ysrc += 2;

		*dest++ = CLIP(*ysrc + u1);	// r
		*dest++ = CLIP(*ysrc - rg);	// g
		*dest++ = CLIP(*ysrc + v1);	// b

		ysrc += 2;
		usrc += 4;
		vsrc += 4;
	}
}

void UYVY_to_BGR888(void *src,void *dst,const int width,const int height)
{
	uint i;
	const uint pix_len = width * height;
	const uchar *ysrc = (const uchar*)src;
	const uchar *usrc = (const uchar*)src + 1;
	const uchar *vsrc = (const uchar*)src + 3;
	uchar *dest = (uchar*)dst;

	for (i = 0; i < pix_len; i += 2)
	{
		const int u1 = (((*usrc - 128) << 7) +  (*usrc - 128)) >> 6;
		const int rg = (((*usrc - 128) << 1) +  (*usrc - 128) + 
						((*vsrc - 128) << 2) + ((*vsrc - 128) << 1)) >> 3;
		const int v1 = (((*vsrc - 128) << 1) +  (*vsrc - 128)) >> 1;

		*dest++ = CLIP(*ysrc + v1);	// b
		*dest++ = CLIP(*ysrc - rg);	// g
		*dest++ = CLIP(*ysrc + u1);	// r

		ysrc += 2;

		*dest++ = CLIP(*ysrc + v1);	// b
		*dest++ = CLIP(*ysrc - rg);	// g
		*dest++ = CLIP(*ysrc + u1);	// r

		ysrc += 2;
		usrc += 4;
		vsrc += 4;
	}
}

void UYVY_to_RGB444(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_RGBA4441(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_RGBA4444(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_RGB555(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_RGBA5551(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_BGR444(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_ABGR1444(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_ABGR4444(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_BGR555(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_ABGR1555(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_BGRA4441(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_BGRA4444(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_BGRA5551(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_RGB332(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_BGR332(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_RGBA5542(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_ABGR2554(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_RGBA6661(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_ABGR1666(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_RGBA6666(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_ABGR6666(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_RGB666(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_BGR666(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_RGBA5658(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}
void UYVY_to_ABGR8565(void *bsrc,void *bdst,const int width,const int height)	{TRACE_ERROR("Function  not implemented");}

void converter_init(void)
{
	static int _init = 0;
	if ( _init ) return;
	_init = 1;

	#define PROTO_CONV_INIT(name)								\
		cnv_fnc[ name ][ RGB444   ]	= & name ## _to_RGB444;		\
		cnv_fnc[ name ][ RGBA4441 ]	= & name ## _to_RGBA4441;	\
		cnv_fnc[ name ][ RGBA4444 ]	= & name ## _to_RGBA4444;	\
		cnv_fnc[ name ][ RGB555   ]	= & name ## _to_RGB555;		\
		cnv_fnc[ name ][ RGBA5551 ]	= & name ## _to_RGBA5551;	\
		cnv_fnc[ name ][ RGB565   ]	= & name ## _to_RGB565;		\
		cnv_fnc[ name ][ RGB888   ]	= & name ## _to_RGB888;		\
		cnv_fnc[ name ][ RGBA8888 ]	= & name ## _to_RGBA8888;	\
																\
		cnv_fnc[ name ][ BGR444   ]	= & name ## _to_BGR444;		\
		cnv_fnc[ name ][ ABGR1444 ]	= & name ## _to_ABGR1444;	\
		cnv_fnc[ name ][ ABGR4444 ]	= & name ## _to_ABGR4444;	\
		cnv_fnc[ name ][ BGR555   ]	= & name ## _to_BGR555;		\
		cnv_fnc[ name ][ ABGR1555 ]	= & name ## _to_ABGR1555;	\
		cnv_fnc[ name ][ BGR565   ]	= & name ## _to_BGR565;		\
		cnv_fnc[ name ][ BGR888   ]	= & name ## _to_BGR888;		\
		cnv_fnc[ name ][ ABGR8888 ]	= & name ## _to_ABGR8888;	\
																\
		cnv_fnc[ name ][ BGRA4441 ]	= & name ## _to_BGRA4441;	\
		cnv_fnc[ name ][ BGRA4444 ]	= & name ## _to_BGRA4444;	\
		cnv_fnc[ name ][ BGRA5551 ]	= & name ## _to_BGRA5551;	\
		cnv_fnc[ name ][ BGRA8888 ]	= & name ## _to_BGRA8888;	\
																\
		cnv_fnc[ name ][ RGB332	  ]	= & name ## _to_RGB332;		\
		cnv_fnc[ name ][ BGR332   ]	= & name ## _to_BGR332;		\
		cnv_fnc[ name ][ RGBA5542 ]	= & name ## _to_RGBA5542;	\
		cnv_fnc[ name ][ ABGR2554 ]	= & name ## _to_ABGR2554;	\
		cnv_fnc[ name ][ RGBA6661 ]	= & name ## _to_RGBA6661;	\
		cnv_fnc[ name ][ ABGR1666 ]	= & name ## _to_ABGR1666;	\
		cnv_fnc[ name ][ RGBA6666 ]	= & name ## _to_RGBA6666;	\
		cnv_fnc[ name ][ ABGR6666 ]	= & name ## _to_ABGR6666;	\
		cnv_fnc[ name ][ RGB666   ]	= & name ## _to_RGB666;		\
		cnv_fnc[ name ][ BGR666   ]	= & name ## _to_BGR666;		\
		cnv_fnc[ name ][ RGBA5658 ]	= & name ## _to_RGBA5658;	\
		cnv_fnc[ name ][ ABGR8565 ]	= & name ## _to_ABGR8565;	\
																\
		cnv_fnc[ name ][ YV12     ]	= & name ## _to_YV12;		\
		cnv_fnc[ name ][ I420     ]	= & name ## _to_I420;		\
		cnv_fnc[ name ][ NV12     ]	= & name ## _to_NV12;		\
		cnv_fnc[ name ][ Y41P     ]	= & name ## _to_Y41P;		\
		cnv_fnc[ name ][ Y411     ]	= & name ## _to_Y411;		\
		cnv_fnc[ name ][ YUY2     ]	= & name ## _to_YUY2;		\
		cnv_fnc[ name ][ UYVY     ]	= & name ## _to_UYVY;		\


	PROTO_CONV_INIT( RGB444  );
	PROTO_CONV_INIT( RGBA4441 );
	PROTO_CONV_INIT( RGBA4444 );
	PROTO_CONV_INIT( RGB555  );
	PROTO_CONV_INIT( RGBA5551 );
	PROTO_CONV_INIT( RGB565  );
	PROTO_CONV_INIT( RGB888  );
	PROTO_CONV_INIT( RGBA8888 );

	PROTO_CONV_INIT( BGR444  );
	PROTO_CONV_INIT( ABGR1444 );
	PROTO_CONV_INIT( ABGR4444 );
	PROTO_CONV_INIT( BGR555  );
	PROTO_CONV_INIT( ABGR1555 );
	PROTO_CONV_INIT( BGR565  );
	PROTO_CONV_INIT( BGR888  );
	PROTO_CONV_INIT( ABGR8888 );

	PROTO_CONV_INIT( BGRA4441 );
	PROTO_CONV_INIT( BGRA4444 );
	PROTO_CONV_INIT( BGRA5551 );
	PROTO_CONV_INIT( BGRA8888 );

	PROTO_CONV_INIT( RGB332 );
	PROTO_CONV_INIT( BGR332 );
	PROTO_CONV_INIT( RGBA5542 );
	PROTO_CONV_INIT( ABGR2554 );
	PROTO_CONV_INIT( RGBA6661 );
	PROTO_CONV_INIT( ABGR1666 );
	PROTO_CONV_INIT( RGBA6666 );
	PROTO_CONV_INIT( ABGR6666 );
	PROTO_CONV_INIT( RGB666 );
	PROTO_CONV_INIT( BGR666 );
	PROTO_CONV_INIT( RGBA5658 );
	PROTO_CONV_INIT( ABGR8565 );

	PROTO_CONV_INIT( YV12 );
	PROTO_CONV_INIT( I420 );
	PROTO_CONV_INIT( NV12 );
	PROTO_CONV_INIT( Y41P );
	PROTO_CONV_INIT( Y411 );
	PROTO_CONV_INIT( YUY2 );
	PROTO_CONV_INIT( UYVY );

	#undef PROTO_CONV_INIT
}

int converter( void *bsrc, void *bdst, const int width, const int height, const int from, const int to )
{
	CONV convertor = 0;

	TRACE_DEBUG( "converter() :: from: " << Fmt2Str(from) << " >> to: " << Fmt2Str(to) );

	if ( from >= FMT_LAST || to >= FMT_LAST )
		return 0;

	converter_init();

	convertor = cnv_fnc[from][to];

	if ( !convertor )
		return 0;

	convertor( bsrc, bdst, width, height );

	return 1;
}
	
// -----------------------------------------------------------------------------
// converter.cxx - Last Change: $Date: 2012-05-15 23:36:52 $ - End Of File
// -----------------------------------------------------------------------------
